#include <bits/stdc++.h>
using namespace std;
inline int Set(int N, int pos) { return N = N | (1 << pos); }
inline int Reset(int N, int pos) { return N = N & ~(1 << pos); }
inline bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
template <class T>
T gcd(T a, T b) {
  return (!b) ? a : gcd(b, a % b);
}
template <class T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == 'S' && s[i + 1] == 'T') {
      for (int j = i, k = i + 1; j >= 0; j--, k++) {
        if (k >= s.size() || s[j] == '-1') break;
        if (s[j] == 'S' && s[k] == 'T') {
          s[j] = s[k] = -1;
        } else {
          i = k - 1;
          break;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    ans += (s[i] != -1);
  }
  cout << ans << endl;
  return 0;
}
