#Lutece2818. Niuma的rating

Niuma的rating

Migrated from Lutece 2818 Niuma的rating

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

Niuma\texttt{Niuma}闲来无事,于是打开了 cfcf,查看自己的 ratingrating 曲线,突然他发现自己的 ratingrating 曲线呈现出某种重复的特征,如图中所示,在 A,B,CA,B,C 连续的三段时间里,AA 段和 CC 段自己的ratingrating曲线的趋势完全相同(即平移后可以重合)。现在Niuma\texttt{Niuma}有了一个奇怪的想法,他想固定 BB 段时间的长度,同时询问你 ratingrating 曲线中有多少个连续的子段,满足将其分解为 A,B,CA,B,C 三段后,BB 段的长度为给定的 mm,且 A,CA,C 两段的变化趋势相同。

DjTxZ.png

Input

第一行两个整数 n,mn,m ,表示Niuma\texttt{Niuma}总共打了 nncfcf ,他希望固定的B段的时间长度为 mm,你可以认为两次相邻的 cfcf 之间的时间长度总是为 11 第二行 nn 个正整数 cic_i 表示每次ratingrating

Output

一行一个整数,表示满足条件的子段数量

Samples

15 2
1 1 3 2 8 8 8 4 6 5 5 5 1 3 2
3

Constraints

1mn3×1051\le m \le n\le 3 \times 10^5, 1ci1091\le c_i\le 10^9

Note

对于样例,和题干中图例一样,满足条件的子段为[5,13],[6,14],[7,15][5,13] , [6,14] , [7,15][7,15][7,15] 这一段为例,可以发现以 [10,12][10,12] 作为 BB 段(时间长度为 22 ),前后的趋势恰好相同,所以满足条件

Resources

2022 UESTC ICPC Training for String and Search Algorithm