#include <bits/stdc++.h>
using namespace std;
bool cmp_P(const pair<long long int, long long int> &a,
           const pair<long long int, long long int> &b) {
  return a.second < b.second;
}
int main() {
  string X;
  int N, num = 0;
  cin >> X;
  for (int i = 0; i < (int)(X.size()); i++) {
    if (X[i] == 'S') {
      num = max(num, i);
      break;
    }
  }
  for (int i = 0; i < (int)(X.size()); i++) {
    if (X[X.size() - i - 1] == 'T') {
      num = max(num, i);
      break;
    }
  }
  cout << 2 * num << endl;
  return 0;
}
int par[100001];
int ranks[100001];
void init(int n) {
  for (int i = 0; i < (int)(n); i++) {
    par[i] = i;
    ranks[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (ranks[x] < ranks[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (ranks[x] == ranks[y]) ranks[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
