#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
string s;
int main() {
  cin >> s;
  int ans = s.size();
  int x, y, tmp = 0;
  do {
    for (int i = tmp; i < s.size() - 1; i++) {
      if (s[i] == 'S' && s[i + 1] == 'T') {
        x = i, y = i + 1, tmp = i + 2;
        break;
      }
      if (i == s.size() - 2) {
        cout << ans;
        return 0;
      }
    }
    while (x >= 0 && y < s.size() && s[x] == 'S' && s[y] == 'T') {
      x--;
      y++;
      tmp++;
      ans -= 2;
    }
    tmp--;
    if (tmp >= s.size() - 2) {
      cout << ans;
      return 0;
    }
  } while (1);
}
