Alice and Bob have stopped playing games. They became friends again. They both agreed that is their favorite integer.
Not only favorite integer, they are also agreeing to decide their favorite arrays, strings, geometrical shapes etc. Sometimes things are interrelated. Their favorite integer has a role to decide their favorite arrays.
To decide whether an array is their favorite, they will multiply the frequencies of every distinct element occurring in that array. Frequency of an element in that array is the number of times the element occurs in that array. If the product is exactly , the array must be their favorite.
For example, if , will be one of their favorite arrays. Here they will calculate the product of frequencies of , , and . It is . Similarly, if , is one of their favorite arrays.
Charlie is acting like their enemy now, he brought an array of integers. Alice and Bob must reply how many sub-arrays of it are their favorite. That is, how many pairs of integers and exist, such that and array is their favorite.
None of Alice and Bob can do it without your help. Help the friends.
First line of input will have two space-separated integers , that is the size of the Charlie’s array and , their favorite integer.
Second line of input will have space-separated integers, denoting the array as , ,, .
In one line, print total number of sub-arrays of that are their favorite.
Input | Output |
---|---|
5 1 1 2 3 4 5 | 15 |
Input | Output |
---|---|
12 4 6 1 1 2 2 3 4 5 5 6 6 1 | 20 |