#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  bool flag = true;
  while (flag) {
    flag = false;
    bool beforeisS = false;
    int snum;
    for (int i = 0; i < x.size(); i++) {
      if (x[i] == 'A') {
        continue;
      }
      if (beforeisS && x[i] == 'T') {
        x[snum] = 'A';
        x[i] = 'A';
        beforeisS = false;
        flag = true;
        continue;
      }
      if (x[i] == 'S') {
        beforeisS = true;
        snum = i;
        continue;
      }
      beforeisS = false;
    }
  }
  int ans = 0;
  for (int i = 0; i < x.size(); i++) {
    if (x[i] != 'A') ans++;
  }
  cout << ans;
}
