#include <iostream>
#include<vector>
using namespace std;
int main() {
vector<int>arr={2,5,2,5,2,5,1,1};
int d=5,m=2,n=arr.size();
int count=0;
for(int i=0;i<n;i++){
int d_count=0;
for(int j=i;j<n;j++){
if(arr[j]==d){
d_count++;
}
if(d_count==m){
count++;
}
}
}
cout<<count;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTx2ZWN0b3I+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCXZlY3RvcjxpbnQ+YXJyPXsyLDUsMiw1LDIsNSwxLDF9OwoJaW50IGQ9NSxtPTIsbj1hcnIuc2l6ZSgpOwoJaW50IGNvdW50PTA7Cglmb3IoaW50IGk9MDtpPG47aSsrKXsKCQlpbnQgZF9jb3VudD0wOwoJCWZvcihpbnQgaj1pO2o8bjtqKyspewoJCQlpZihhcnJbal09PWQpewoJCQkJZF9jb3VudCsrOwoJCQl9CgkJCWlmKGRfY291bnQ9PW0pewoJCQkJY291bnQrKzsKCQkJfQoJCX0KCX0KCWNvdXQ8PGNvdW50OwoJcmV0dXJuIDA7Cn0=