func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[610000], i, j, k, l, n, m, p[610000], t, last, o, r, mid;   char c[610000];   bool check(int mid) {     int tmp = 1e9, res = 0;     p[0] = mid;     m = last;     for (i = 1; i <= n; ++i) {       p[i] = p[i - 1] + a[i];       if (p[i] == 0 && p[i - 1] == -1) m = max(m, i);     }     if (m == 0) return 1;     for (i = 1; i <= m; ++i) {       if (p[i - 1] == 0 && p[i] == -1) {         o = i;         tmp = min(tmp, res + (m - i) * 2);       }       if (p[i - 1] == -1 && p[i] == 0) {         if (i == m) tmp = min(tmp, res + m - o);         res += (i - o) * 2;       }       res++;     }     tmp = min(tmp, res - 1);     return tmp + 1 <= t;   }   int main() {     scanf( %d%d%s , &n, &t, c + 1);     for (i = 1; i <= n; ++i) a[i] = c[i] ==  H  ? -1 : c[i] ==  S  ? 1 : 0;     for (i = 1; i <= n; ++i) {       if (a[i] == -1) r++, last = i;       if (a[i] == 1) l--;     }     l += r;     if (l < 0) l = 0;     if (last > t) {       printf( -1 n );       exit(0);     }     while (l <= r) {       mid = (l + r) / 2;       if (check(mid))         r = mid - 1;       else         l = mid + 1;     }     printf( %d n , r + 1);   }   