#include <bits/stdc++.h>
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1 << 21;
using pii = std::pair<int, int>;
int gcd(int M, int N) {
  if (M < N) std::swap(M, N);
  if (N == 0)
    return M;
  else
    return gcd(N, M % N);
}
int main(void) {
  int N;
  std::string s;
  std::cin >> s;
  std::vector<int> it_count;
  int t_count = (int)s.size() / 2, temp = 0;
  for (size_t i = 0; i < s.size(); ++i) {
    if (s[i] == 'S') {
      it_count.push_back(t_count - temp);
    } else
      temp++;
  }
  int res = 0;
  for (size_t i = 0; i < it_count.size(); ++i) {
    if (it_count[i] >= 1) res += 2;
  }
  std::cout << (int)s.size() - res << std::endl;
  return 0;
}
