#include <bits/stdc++.h>
void divide_cube() {
  long long a, b, c;
  long long m1, m2;
  std::cin >> a >> b >> c;
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
    std::cout << 0 << std::endl;
  else {
    m1 = std::min(a, b);
    if (m1 == a)
      m2 = std::min(b, c);
    else
      m2 = std::min(a, c);
    long long result = m1 * m2;
    std::cout << result << std::endl;
  }
}
void STring() {
  std::string x;
  std::cin >> x;
  std::string y, y2;
  int n = x.size();
  int nt = 0;
  int ns = 0;
  int i = n - 1;
  std::cout << n << std::endl;
  int tcnt = 0;
  int scnt = 0;
  int result = n;
  while (i >= 0) {
    y = x.substr(i, 1);
    if (tcnt == 0 && y == "S") {
      i--;
    } else if (tcnt != 0 && y == "S") {
      i--;
      scnt++;
      if (i < 0) result = result - 2 * std::min(scnt, tcnt);
    } else if (scnt != 0 && y == "T") {
      i--;
      result = result - 2 * std::min(scnt, tcnt);
      tcnt = 1;
      scnt = 0;
    } else if (scnt == 0 && y == "T") {
      i--;
      tcnt++;
    }
  }
  std::cout << result << std::endl;
}
int main() {
  STring();
  return 0;
}
