407956: GYM102948 F Hopping Between Lily Pads
Description
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:
- Jump forward $$$N$$$ lily pads
- 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!
InputThe 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.
OutputA 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.
ExampleInput4 2 100 4 1 2 3 4Output
2