#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
const long long INF = (1ll << 60);
template <class T>
bool umax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool umin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int findGCD(int arr[], int n) {
  int result = arr[0];
  for (int i = 1; i < n; i++) result = gcd(arr[i], result);
  return result;
}
template <typename T>
T lcm(T m, T n) {
  if ((0 == m) || (0 == n)) return 0;
  return ((m / gcd(m, n)) * n);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};
int main() {
  string X;
  cin >> X;
  int Snum = 0, MaxT = X.size() / 2;
  int Tnum = 0;
  for (auto c : X) {
    if (c == 'S') {
      Snum++;
    } else {
      Tnum++;
    }
    if (Tnum == MaxT) break;
  }
  cout << 2 * (MaxT - Snum) << endl;
  return 0;
}
