407945: GYM102947 F Hopping Between Lily Pads

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Hopping Between Lily Padstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Justin the frog is hopping between lily pads. He starts at lily pad $$$0$$$, and there are $$$L + 1$$$ total lily pads. He can do one of two things:

  1. Jump forward $$$N$$$ lily pads
  2. Jump backward $$$M$$$ lily pads

Justin must land on a lily pad after every jump, or he will fall into the water. Today, Justin is hungry and he notices that there are $$$F$$$ flies on some lily pads. If Justin can make it to those lily pads somehow, he will be able to eat the flies. However, due to his restrictive movement, he may not be able to reach all lily pads. Help Justin determine how many flies he can reach!

Input

The first line of the input will contain $$$N (1 \le N \le 100), M (1 \le M \le 100)$$$, and $$$L (1 \le L \le 10^4)$$$, which detail the number of pads $$$N$$$ that Justin can move forward in a jump, the number of pads $$$M$$$ that Justin can move backward in a jump, and the number of the very last lily pad.

The next line of the input will have a single integer $$$F$$$ $$$(1 \le F \le 100)$$$, the number of flies.

The next $$$F$$$ lines will each contain a single integer $$$f_i$$$ where $$$0 \le f_i \le L$$$, the location of the $$$i^{th}$$$ fly.

Output

A single integer $$$f$$$, the number of flies that Justin can snack on. Note that this is the number of flies that Justin can reach, not the number of flies Justin can snack on in one trip.

ExampleInput
4 2 100
4
1
2
3
4
Output
2

加入题单

上一题 下一题 算法标签: