func_code_string: #include <bits/stdc++.h>   using namespace std;   const int E9 = 1e9;   const int E8 = 1e8;   const int E7 = 1e7;   const int E6 = 1e6;   const int E5 = 1e5;   const int E4 = 1e4;   const int E3 = 1e3;   const int N = 5e5 + 7;   const int MOD = 1e9 + 7;   const long long INF = 1e18;   int n;   bool dp[101][51][2][201];   string s;   void calc(int com, int kol, int dir, int pos) {     if (dp[com][kol][dir][pos]) {       return;     }     dp[com][kol][dir][pos] = 1;     if (com == (int)s.size()) {       return;     }     for (int i = 0; i <= n - kol; i++) {       if (i % 2 == 0) {         if (s[com] ==  F ) {           calc(com + 1, kol + i, dir, pos + (dir == 0 ? 1 : -1));         } else {           calc(com + 1, kol + i, (dir ^ 1), pos);         }       } else {         if (s[com] ==  T ) {           calc(com + 1, kol + i, dir, pos + (dir == 0 ? 1 : -1));         } else {           calc(com + 1, kol + i, (dir ^ 1), pos);         }       }     }   }   int main() {     cin >> s >> n;     calc(0, 0, 0, 100);     int sz = (int)s.size();     int mx = 0;     for (int i = 0; i <= 200; i++) {       if (dp[sz][n][0][i] || dp[sz][n][1][i]) {         mx = max(mx, abs(i - 100));       }     }     cout << mx;   }   