Under construction

Still being built. Things may change

Robot

Time limit6sMemory limit1024 MB

Summary
Count how many times a robot that repeats a list of move lengths, turning right after each move, is at a given point before its battery runs out.
Level

Medium7 of 10

Topics
Math, Prefix sum, Simulation, Implementation
Solved
No attempts yet

Problem

The robot starts at (0,0)(0, 0) on a coordinate plane and faces north (the direction of increasing yy). You program it with a sequence of commands d1,d2,…,dnd_1, d_2, \ldots, d_n. When the robot is switched on, it performs moves in order. Move ii (for i≥1i \ge 1) drives forward d((i−1) mod n)+1d_{((i-1) \bmod n)+1} units, then turns 90 degrees to the right.

The battery lasts for tt seconds. Driving one unit takes 1 second, and each 90 degree turn takes 1 second.

Given a point (x,y)(x, y), count how many times the robot is at that point before the battery runs out.

Input

The first line contains two integers nn and tt (1≤n≤1000001 \le n \le 100000, 1≤t≤10181 \le t \le 10^{18}), the length of the robot's program and the battery time in seconds. The second line contains nn integers d1,…,dnd_1, \ldots, d_n (1≤di≤1091 \le d_i \le 10^9), the commands in order. The third line contains two integers xx and yy (−109≤x,y≤109-10^9 \le x, y \le 10^9), the point being queried.

Output

Print one integer: the number of moments at which the robot is at the point (x,y)(x, y). A moment at time 0 or at time tt counts too.

Hint

In the sample, the robot is at the point (3,2)(3, 2) at 6 and 22 seconds after it is switched on. The figure below shows the robot's route.

Examples1

  1. Example 1

    Input
    4 28
    2 3 1 2
    3 2
    
    Expected output
    2