A - 倍数チェック 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

高橋君は N 個の整数 A_1, A_2, \ldots, A_N を持っています。

正の整数 K が与えられるので、A_1, A_2, \ldots, A_N のそれぞれについて K で割り切れるかを調べ、K で割り切れるものの個数を求めてください。

ここで、整数 aK で割り切れるとは、a = K \times q を満たす整数 q が存在することをいいます。例えば、-63 で割り切れ、0 は任意の正の整数で割り切れます。

制約

  • 1 \leq N \leq 5 \times 10^5
  • 1 \leq K \leq 10^9
  • -10^9 \leq A_i \leq 10^9
  • 入力はすべて整数である

入力

N K
A_1 A_2 \cdots A_N

1 行目には、整数の個数 N と割る数 K がスペース区切りで与えられる。

2 行目には、N 個の整数 A_1, A_2, \ldots, A_N がスペース区切りで与えられる。

出力

K で割り切れる整数の個数を 1 行で出力してください。


入力例 1

5 3
1 3 6 -4 0

出力例 1

3

入力例 2

6 5
1 2 3 4 6 7

出力例 2

0

入力例 3

12 7
14 -21 28 5 0 49 56 -1 70 100 -98 13

出力例 3

8

入力例 4

30 12
12 24 36 48 60 72 84 96 108 120 -12 -24 -36 -48 -60 -72 1 11 13 25 37 49 61 73 85 97 0 144 -120 1000000000

出力例 4

19

入力例 5

1 1000000000
-1000000000

出力例 5

1

Score : 200 pts

Problem Statement

Takahashi has N integers A_1, A_2, \ldots, A_N.

Given a positive integer K, determine for each of A_1, A_2, \ldots, A_N whether it is divisible by K, and find the number of integers that are divisible by K.

Here, an integer a is divisible by K means that there exists an integer q such that a = K \times q. For example, -6 is divisible by 3, and 0 is divisible by any positive integer.

Constraints

  • 1 \leq N \leq 5 \times 10^5
  • 1 \leq K \leq 10^9
  • -10^9 \leq A_i \leq 10^9
  • All inputs are integers

Input

N K
A_1 A_2 \cdots A_N

The first line contains the number of integers N and the divisor K, separated by a space.

The second line contains N integers A_1, A_2, \ldots, A_N, separated by spaces.

Output

Print the number of integers that are divisible by K on a single line.


Sample Input 1

5 3
1 3 6 -4 0

Sample Output 1

3

Sample Input 2

6 5
1 2 3 4 6 7

Sample Output 2

0

Sample Input 3

12 7
14 -21 28 5 0 49 56 -1 70 100 -98 13

Sample Output 3

8

Sample Input 4

30 12
12 24 36 48 60 72 84 96 108 120 -12 -24 -36 -48 -60 -72 1 11 13 25 37 49 61 73 85 97 0 144 -120 1000000000

Sample Output 4

19

Sample Input 5

1 1000000000
-1000000000

Sample Output 5

1