#include <bits/stdc++.h>   using namespace std;   string s;   int n, m;   int f[150][150][250][2];   int main() {     cin >> s;     n = s.size();     scanf( %d , &m);     f[0][m][n][1] = true;     for (int i = 0; i < n; i++)       for (int j = 0; j <= m; j++)         for (int k = 0; k <= n * 2; k++)           for (int l = 0; l < 2; l++)             if (f[i][j][k][l])               if (s[i] ==  T ) {                 f[i + 1][j][k][1 - l] = true;                 if (j != 0 && k - 1 + 2 * l >= 0)                   f[i + 1][j - 1][k - 1 + 2 * l][l] = true;               } else {                 if (k - 1 + 2 * l >= 0) f[i + 1][j][k - 1 + 2 * l][l] = true;                 if (j != 0) f[i + 1][j - 1][k][1 - l] = true;               }     int i = 0;     for (int j = 0; j <= m; j++)       if (j % 2 == 0)         for (int k = 0; k <= n * 2; k++)           for (int l = 0; l < 2; l++)             if (f[n][j][k][l]) {               if (k - n < 0 && n - k > i) i = n - k;               if (k - n > 0 && k - n > i) i = k - n;             }     printf( %d n , i);     return 0;   }   