#include <bits/stdc++.h>
using namespace std;
using P = pair<long long int, long long int>;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
struct Edge {
  int to;
  long long int weight;
  Edge(int t, long long int w) : to(t), weight(w) {}
};
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}
string s;
vector<P> v;
int main() {
  cin >> s;
  bool inS = false;
  int s_ct = 0;
  int t_ct = 0;
  for (int i = 0; i < s.size(); ++i) {
    char tmp = s[i];
    if (tmp == 'S') {
      if (inS) {
        s_ct++;
      } else {
        if (s_ct > 0) {
          v.emplace_back(s_ct, t_ct);
        }
        inS = true;
        s_ct = 1;
        t_ct = 0;
      }
    } else {
      if (inS) {
        inS = false;
      }
      t_ct++;
    }
  }
  if (!inS) {
    v.emplace_back(s_ct, t_ct);
  }
  int ans = 0;
  for (auto p : v) {
    ans += 2 * min(p.first, p.second);
  }
  ans = s.size() - ans;
  cout << ans << "\n";
}
