func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, x[105], mem[101][201][51][3], ans;   string s;   int solve(int idx, int pos, int rem, int dir) {     int &ret = mem[idx][100 + pos][rem][dir + 1];     if (rem == 0) {       int cur_dir = dir, sum = 0;       for (int i = idx; i < s.size(); i++)         if (x[i])           sum += cur_dir;         else           cur_dir *= -1;       return abs(pos + sum);     }     if (idx == s.size()) return -1e8;     if (ret != -1) return ret;     int next_dir = (x[idx]) ? dir : -dir;     int c1 = solve(idx + 1, pos + x[idx] * dir, rem, next_dir);     int new_dir = (x[idx]) ? -dir : dir;     int new_pos = (x[idx]) ? pos : pos + dir;     int c2 = -1e8;     if (rem >= 2) c2 = solve(idx, pos, rem - 2, dir);     int c3 = -1e8;     if (rem >= 1) c3 = solve(idx + 1, new_pos, rem - 1, new_dir);     ans = max(ans, max(max(c1, c2), c3));     return ret = ans;   }   int main() {     cin >> s >> n;     memset(mem, -1, sizeof mem);     for (int i = 0; i < s.size(); i++) x[i] = (s[i] ==  F );     cout << max(solve(0, 0, n, -1), solve(0, 0, n, 1));     return 0;   }   