Collecting Stamps 3

둘레 L인 호수 둘레에 놓인 N개의 스탬프를 시작점에서 출발해 제한 시간 Ti 안에 도착해 모을 때, 모을 수 있는 스탬프 개수의 최댓값을 구한다.

어려움8동적 계획법구간누적 합완전 탐색아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

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 N types of stamps situated around the lake. These stamps are numbered from 1 to N, in clockwise order. The perimeter of the lake is L, and the i-th stamp (1 ≤ i ≤ N) is located at Xi 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 i-th stamp (1 ≤ i ≤ N) only if they arrive at where the i-th stamp is located within Ti seconds (inclusive) since the rally starts.

JOI-kun is a participant of the stamp rally. He takes 1 second to move 1 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.

입력

Read the following data from the standard input. Given values are all integers.

N L
X1 . . . XN
T1 . . . TN

출력

Write the answer in one line to the standard output.

제한

  • 1 ≤ N ≤ 200.
  • 2 ≤ L ≤ 1 000 000 000.
  • 1 ≤ Xi < L (1 ≤ i ≤ N).
  • Xi < Xi+1 (1 ≤ i ≤ N − 1).
  • 0 ≤ Ti ≤ 1 000 000 000 (1 ≤ i ≤ N).