Frog Training

You and your friends are frog trainers and your objective is to catch them all! Now, this may seem like an easy task to most, but your purpose in life is to catch the frogs that have specifically fallen into wells and cannot come out on their own. Fortunately, not only are you a frog trainer, but you’re also in the process of getting a CSE degree from THE Pennsylvania State University. Thus, you are able to design and plan different ways that the frogtraining can jump based on the height of the well and frog species. All species of frogtraining only jump at discrete lengths.

Input

The input consists of $2$ lines.

  • Line $1$: A list of numbers, $x_1 \ldots x_ n$ ($1 \le x_ i \le 1\, 000$, $1 \le n \le 20$), separated by spaces that signify the various heights that the specie of frog can jump to. For example, $1$ $3$ $5$ could show that the frog can jump $1$ units high, $3$ units high, or $5$ units high.

  • Line $2$: An integer, $h$ ($1 \le h \le 1\, 000$), that signifies the height of the well the frog is stuck in. For example, $4$ could be the height of the well.

So, the output in this example case would be $3$ because there are $2$ combinations possible given the two inputs: $1$ $1$ $1$ $1$ $1$ and $1$ $1$ $3$.

Output

Output the number of combinations of jumps that your frog can use to jump out of the well.

Sample Input 1 Sample Output 1
1 3 5
4
2
Sample Input 2 Sample Output 2
2 3 5
4
1

Please log in to submit a solution to this problem

Log in