eolymp
bolt
Try our new interface for solving problems
Problems

Shortcut

Shortcut

Time limit 1 second
Memory limit 128 MiB

Pavel has a toy railway. It is very simple. There is a main line consisting of n stations. These stations are numbered from 0 to n1 in order along the line. The distance between the stations i and i + 1 is l[i] centimeters (0i < n1).

Apart from the main line there may be some secondary lines. Each secondary line is a railway line between a station on the main line and a new station that does not lie on the main line. (These new stations are not numbered.) At most one secondary line can start in each station of the main line. The length of the secondary line starting at station i is d[i] centimeters. We use d[i] = 0 to denote that there is no secondary line starting at station i.

prb7977.gif

Pavel is now planning to build one shortcut: an express line between two different (possibly neighboring) stations of the main line. Express line will have length of exactly c centimeters, regardless of what two stations it will connect.

Each segment of the railway, including the new express line, can be used in both directions. The distance between two stations is the smallest length of a route that goes from one station to the other along the railways. The diameter of the whole railway network is the maximum distance among all pairs of stations. In other words, this is the smallest number t, such that the distance between every pair of stations is at most t.

Pavel wants to build the express line in such a way that the diameter of the resulting network is minimized.

Input data

First line contains integers n and c (2n10^6, 1c10^9).

Second line contains integers l[0], ..., l[n − 2] (1l[i]10^9).

Third line contains integers d[0], …, d[n − 1] (0d[i]10^9).

Output data

Print a single integer denoting the smallest possible diameter.

Example 1

The optimal solution is to build the express line between stations 1 and 3, as shown below.

prb7977_1.gif

Examples

Input example #1
4 10
10 20 20
0 40 0 30
Output example #1
80
Input example #2
9 30
10 10 10 10 10 10 10 10
20 0 30 0 0 40 0 40 0
Output example #2
110
Input example #3
4 1
2 2 2
1 10 10 1
Output example #3
21
Input example #4
3 3
1 1
1 1 1
Output example #4
4
Source 2016 IOI Kazan, Russia, Day 1