Problem9967--ABC315 —— G - Ai + Bj + Ck = X (1 <= i, j, k <= N)

9967: ABC315 —— G - Ai + Bj + Ck = X (1 <= i, j, k <= N)

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

You are given integers $N,A,B,C,X$. Find the number of triples of integers $(i,j,k)$ that satisfy all of the following conditions.

-   $1 \le i,j,k \le N$
-   $Ai+Bj+Ck=X$

Input

The input is given from Standard Input in the following format:

```
$N$ $A$ $B$ $C$ $X$
```

Output

Print the answer as an integer.

Constraints

-   All input values are integers.
-   $1 \le N \le 10^6$
-   $1 \le A,B,C \le 10^9$
-   $1 \le X \le 3 \times 10^{15}$

Sample 1 Input

5 3 1 5 15

Sample 1 Output

3

The following three triples satisfy the conditions.

  • (1,2,2) : 3×1+1×2+5×2=15
  • (2,4,1) : 3×2+1×4+5×1=15
  • (3,1,1) : 3×3+1×1+5×1=15

Sample 2 Input

1 1 1 1 1

Sample 2 Output

0

Sample 3 Input

100000 31415 92653 58979 1000000000

Sample 3 Output

2896

Source/Category