Deemo's Problem

View as PDF

Points: 15
Time limit: 0.6s
Memory limit: 256M

Authors:
Problem types

Deemo has found a problem, and he needs your help! Given an array of integers , find the total number of good subarrays.

A subarray is good if it is non-empty and for every number from to , they all appear the same number of times.

Input Specification

The first line of input contains , the length of the array and .

The second line of input will contain space separated integers, .

Output Specification

Output on a single line, the number of good subarrays.

Sample Input 1

3 3
1 2 3

Sample Output 1

1

Sample Input 2

4 3
1 2 3 1

Sample Output 2

2