func_code_string: #include <bits/stdc++.h>   const int MAXN = 100005;   int n;   char s[MAXN];   int B = 0, R = 0;   int main() {     while (scanf( %d , &n) != EOF) {       scanf( %s , s);       int res = 0;       B = 0, R = 0;       char pre;       for (int i = 0; i < n; i++) {         if (i == 0) {           pre = s[0];           continue;         }         if (s[i] != pre) {           pre = s[i];           continue;         }         if (s[i] ==  r ) {           if (R == 0) {             res++;             pre =  b ;             B++;           } else {             pre =  b ;             R--;           }         } else {           if (B == 0) {             res++;             pre =  r ;             R++;           } else {             pre =  r ;             B--;           }         }       }       int ans = res;       res = 0;       B = 0, R = 0;       for (int i = 0; i < n; i++) {         if (i == 0) {           if (s[0] ==  b ) {             pre =  r ;             R++;             res++;           } else {             pre =  b ;             B++;             res++;           }           continue;         }         if (s[i] != pre) {           pre = s[i];           continue;         }         if (s[i] ==  r ) {           if (R == 0) {             res++;             pre =  b ;             B++;           } else {             pre =  b ;             R--;           }         } else {           if (B == 0) {             res++;             pre =  r ;             R++;           } else {             pre =  r ;             B--;           }         }       }       printf( %d n , res < ans ? res : ans);     }   }   