P13151 [HackerEarth] xenny and k matching
普及
题目描述

Xenny had N boxes with an integer printed on each of the boxes.

He wanted to find out how many distinct pairs of boxes that were at distance k from each other, had an absolute value of difference or sum that was a multiple of k.

Help him in this task.

(Note: Consider two indices i1 and i2. Pairs (i1, i2) and (i2, i1) are not considered to be distinct)

Input Format:

First line contains 2 space-separated integers - N and k.
Second line contains N space-separated integers.

Output Format:

Output a single line, denoting the number of required pairs.

Constraints:

2 ≤ N ≤ 10^6

1 ≤ k ≤ 1000

-1000000 ≤ Integer on box ≤ 1000000

SAMPLE INPUT
10 1
1 2 3 4 5 6 7 8 9 10

SAMPLE OUTPUT
9

输入格式

见题面

输出格式

见题面

样例输入
10 1 1 2 3 4 5 6 7 8 9 10 SAMPLE
样例输出
9