## JOI '19 Final P3 - Collecting Stamps 3

View as PDF

Points: 15
Time limit: 1.0s
Memory limit: 512M

Problem type

Republic of IOI, where JOI-kun lives, is famous for a large lake. Today, a stamp rally event takes place around the lake.

There are types of stamps situated around the lake. These stamps are numbered from to , in clockwise order. The perimeter of the lake is , and the -th stamp () is located at meters clockwise from the starting point of the stamp rally.

Each participant stands at the starting point of the stamp rally. After the rally starts, each participant can move around the lake, both clockwise and counter-clockwise. Each participant can collect the -th stamp () only if they arrive at where the -th stamp is located within seconds (inclusive) since the rally starts.

JOI-kun is a participant of the stamp rally. He takes second to move meter. You can ignore all the other times which he takes.

Write a program that, given the number of types of stamps, the perimeter of the lake, where each stamp is located, and the time until which JOI-kun can collect each stamp, calculates the maximum number of types of stamps he can collect in total.

#### Input Specification

The first line contains two space separated integers and (, ).

The second line contains integers, ( and ).

The third line contains integers, ().

#### Output Specification

Write the answer in one line to the standard output.

#### Sample Input 1

6 25
3 4 7 17 21 23
11 7 17 10 8 10

#### Sample Output 1

4

#### Sample Input 2

5 20
4 5 8 13 17
18 23 15 7 10

#### Sample Output 2

5