fork download
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. string s;
  6.  
  7. int main(){
  8. cin >> s;
  9. int n = s.size();
  10. int so_xau_con = 0;
  11. for(int i = 0; i < n; i++){
  12. if(s[i] != s[(i+1)%n]) so_xau_con++;
  13. }
  14. if(so_xau_con == 0) cout << 0;
  15. else cout << (so_xau_con - 2)/2;
  16. }
  17.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Standard output is empty