fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int n ; cin>>n;
  8. int k ; cin>>k;
  9. string s;
  10. cin>>s;
  11.  
  12.  
  13. int ans = 0 ;
  14. for(int i = 0 ; i<n;i++){
  15. int count = 0 ;
  16. for(int j = i ; j<n;j++){
  17. if(s[j]=='5'){
  18. count++;
  19.  
  20. }
  21. if(count==k) ans++;
  22. }
  23.  
  24. }
  25. cout<<ans;
  26. return 0;
  27. }
Success #stdin #stdout 0s 5316KB
stdin
5
2
52525
stdout
4