func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int n;   char cmd[1000001];   bool sym(int p) {     int rm = 0, cur = 0;     for (int i = 0; i < n - 1; ++i) {       if (cur > p + 1 && cmd[i] ==  L )         cur--;       else if (cmd[i] ==  R )         rm = max(rm, ++cur);     }     return cur + 1 > rm;   }   int main() {     scanf( %s , cmd);     n = strlen(cmd);     if (cmd[n - 1] ==  L )       for (int i = 0; i < n; ++i) cmd[i] = cmd[i] ==  R  ?  L  :  R ;     if (sym(-mod))       puts( 1 );     else {       int a = -mod, b = 0;       while (b - a > 1) {         int m = (a + b) >> 1;         if (sym(m))           b = m;         else           a = m;       }       printf( %d n , -b);     }     return 0;   }   