fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. br.readLine();
  13. int cnt = 0;
  14. String str = br.readLine();
  15. int ans = 0;
  16. for(int i=0;i<str.length();i++) {
  17. if(str.charAt(i)=='x') {
  18. cnt++;
  19. } else {
  20. cnt = 0;
  21. }
  22. if(cnt>=3) {
  23. ans++;
  24. }
  25. }
  26. System.out.print(ans);
  27. }
  28. }
Success #stdin #stdout 0.06s 32464KB
stdin
10
xxxxxxxxxx
stdout
8