#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 922337203685477580;
long long gcd(long long x, long long y) {
  long long tmp = 0;
  if (x < y) {
    tmp = x;
    x = y;
    y = tmp;
  }
  while (y > 0) {
    long long r = x % y;
    x = y;
    y = r;
  }
  return x;
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
long long kaijo(long long k) {
  long long sum = 1;
  for (long long i = 1; i <= k; ++i) {
    sum *= i;
    sum %= 1000000000 + 7;
  }
  return sum;
}
long long lmax(long long s, long long t) {
  if (s > t) {
    return s;
  } else {
    return t;
  }
}
long long lmin(long long s, long long t) {
  if (s < t) {
    return s;
  } else {
    return t;
  }
}
long long dp[100010];
int main() {
  string s;
  cin >> s;
  int left = 0, right = 0;
  while (s[left] == 'T' && left <= s.length() - 1) left++;
  while (s[s.length() - 1 - right] == 'S' && right <= s.length() - 1) right++;
  cout << max(left, right) * 2 << endl;
  return 0;
}
