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