fork download
  1. #include <bits/stdc++.h>
  2. #define el endl
  3. using namespace std;
  4.  
  5. void input()
  6. {
  7. if (fopen("in.txt", "r"))
  8. {
  9. freopen("in.txt", "r", stdin);
  10. freopen("out.txt", "w", stdout);
  11. }
  12. }
  13.  
  14. int main()
  15. {
  16. input();
  17.  
  18. int n;
  19. cin >> n;
  20. string s;
  21. cin >> s;
  22.  
  23. int count = 1;
  24. for (int i = 1; i < n; i++)
  25. {
  26. if (s[i] != s[i - 1])
  27. count++;
  28. }
  29. cout << count << el;
  30.  
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5328KB
stdin
Standard input is empty
stdout
1