func_code_string: #include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:400000000 )   int n, t;   int H;   string s;   int ok(int rest, int last) {     int time = 0;     for (int i = 0; i < (last + 1); i++) {       time++;       if (time > t) return 0;       if (time + (last - i) * 2 <= t) return 1;       if (s[i] ==  S ) rest++;       if (s[i] ==  H ) rest--;       if (rest < 0) {         int from = i;         while (rest < 0) {           i++;           if (s[i] ==  S ) rest++;           if (s[i] ==  H ) rest--;         }         time += (i - from) * 3;       }     }     return time <= t;   }   int main() {     cin >> n >> t >> s;     for (int i = 0; i < (n); i++) H += s[i] ==  H ;     int lo = -1, hi = H + 1;     while (lo + 1 < hi) {       int mi = (lo + hi) / 2;       int rest = mi;       int last = 0;       for (int i = 0; i < (n); i++) {         if (s[i] ==  S ) {           if (rest < 0) last = i;           rest++;         }         if (s[i] ==  H ) {           last = i;           rest--;         }       }       if (rest < 0)         lo = mi;       else {         if (ok(mi, last))           hi = mi;         else           lo = mi;       }     }     if (hi == H + 1)       cout << -1 << endl;     else       cout << hi << endl;   }   