#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  vector<vector<char>> v;
  for (char c : s) {
    if (v.empty()) {
      v.push_back(vector<char>({c}));
    } else {
      if (v.back()[0] == c) {
        v.back().push_back(c);
      } else {
        v.push_back(vector<char>({c}));
      }
    }
  }
  if (v[0][0] == 'S') {
    int count = 0;
    for (int i = 0; i + 1 < v.size(); i += 2) {
      count += min(v[i].size(), v[i + 1].size());
    }
    cout << s.size() - 2 * count;
  } else {
    int count = 0;
    for (int i = 1; i + 1 < v.size(); i += 2) {
      count += min(v[i].size(), v[i + 1].size());
    }
    cout << s.size() - 2 * count;
  }
}
