Yánshí

Time limit: 0.6s Memory limit: 128MB Input: Output:

Bun \dots - Sun Tzu

Task

On his daily walking trip to 7-eleven\text{7-eleven}, Ion Mergătorul got bored of tripping over rocks so he tripped over an array AA with NN integers and positive integer KK. A subarray A[ij]A[i \dots j] is called suntzu if every element in the subarray appears at least KK times in the subarray. Ion wants to know how many suntzu subarrays are there in the array.

Input data

The first line of the input containts two integers NN and KK --- the size of the array and the positive integer KK.

The second line contains NN integers A1,A2,,ANA_1, A_2, \dots, A_N --- the elements of the array.

Output data

The output should contain a single integer --- the number of suntzu subarrays in the array.

Constraints and clarifications

  • 1N250 0001 \leq N \leq 250 \ 000
  • 2KN2 \leq K \leq N
  • 1AiN1 \leq A_i \leq N for all 1iN1 \leq i \leq N
  • At Prosoft @ NT competition, the subtasks were worth 17,22,19,16,2617, 22, 19, 16, 26 points. The problem was configured using the IIOT score distribution for extra challenge.
# Score Constraints
1 2 1N1001 \leq N \leq 100
2 17 1N5 0001 \leq N \leq 5 \ 000
3 13 K=2K = 2
4 14 K10 000K \geq 10 \ 000
5 54 No additional restrictions

Example

stdin

6 2
1 2 2 1 2 1

stdout

6

Explanation

The suntzu arrays are as follows: A[14]A[1 \dots 4], A[15]A[1 \dots 5], A[16]A[1 \dots 6], A[23]A[2 \dots 3], A[26]A[2 \dots 6], A[36]A[3 \dots 6]

Log in or sign up to be able to send submissions!