fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define el "\n"
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define se second
  7. #define fi first
  8. #define be begin()
  9. #define en end()
  10. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  11.  
  12. int main()
  13. {
  14. Faster;
  15. string s; cin >> s;
  16. vector<char> vt;
  17. if(s.size() <= 1)
  18. {
  19. cout << 0;
  20. return 0;
  21. }
  22. vt.push_back(s[0]);
  23. for(int i = 1; i < s.size(); i++)
  24. {
  25. if(vt.back() != s[i]) vt.push_back(s[i]);
  26. }
  27. cout << s.size() - vt.size();
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5288KB
stdin
aabbaaac
stdout
4