#include <bits/stdc++.h>
using namespace std;
bool isOK(int index, int key, vector<int> a) {
  if (a[index] >= key)
    return true;
  else
    return false;
}
int binary_search(int key, vector<int> a) {
  int left = -1;
  int right = (int)a.size();
  while (right - left > 1) {
    int mid = left + (right - left) / 2;
    if (isOK(mid, key, a))
      right = mid;
    else
      left = mid;
  }
  return right;
}
int modpow(int a, int b, int p) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    return modpow((a * a) % p, b / 2, p);
  } else {
    return (a * modpow(a, b - 1, p)) % p;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  vector<char> ans;
  for (int i = 0; i < s.size(); i++) {
    ans.push_back(s.at(i));
  }
  while (ans.size()) {
    bool fin = true;
    for (int i = 0; i < ans.size(); i++) {
      if (i == ans.size() - 1) {
        continue;
      }
      if (ans.at(i) == 'S' && ans.at(i + 1) == 'T') {
        ans.erase(ans.begin() + i);
        ans.erase(ans.begin() + i);
        i--;
        fin = false;
      }
    }
    if (fin) {
      break;
    }
  }
  cout << ans.size() << endl;
  return 0;
}
