#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void ff() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
void in_out_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
int n, m, co, mx, l, r;
bool f;
char arr[25][25];
char ch1, ch2;
void dfs(int i, int j) {
  if (i == l && j == r) f = 1;
  if (i == n || j == m || i == -1 || m == -1 || arr[i][j] == '0' ||
      arr[i][j] != ch1)
    return;
  co++;
  arr[i][j] = '0';
  if (j + 1 == m) {
    dfs(i, 0);
  }
  if (j - 1 == -1) {
    dfs(i, m - 1);
  }
  dfs(i + 1, j);
  dfs(i, j + 1);
  dfs(i, j - 1);
  dfs(i - 1, j);
}
int main() {
  ff();
  string str, st;
  int i = 0, j = 1, co = 0;
  cin >> str;
  while (j < str.size()) {
    if (str[i] == 'S' && str[j] == 'T') {
      i--, j++, co++;
      if (i == -1) i = j, j = j + 1;
    } else
      i = j, j++;
  }
  int n = str.size();
  cout << n - co * 2 << endl;
  return 0;
}
