#include <bits/stdc++.h>
using namespace std;
char a[200001];
int n, sum;
int main() {
  cin >> a;
  n = strlen(a);
  sum = strlen(a);
  for (int i = 0; i < n; i++)
    if (a[i] == 'S')
      for (int j = i + 1; j < n; j++)
        if (a[j] == 'T') {
          sum -= 2;
          a[j] == 'A';
          break;
        }
  cout << sum << endl;
  return 0;
}
