#include <bits/stdc++.h>
using namespace std;
struct Fast {
  Fast() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
  }
} fast;
const int INF = 999999999;
const int MOD = 1e9 + 7;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
inline bool inside(int y, int x, int H, int W) {
  return y >= 0 && x >= 0 && y < H && x < W;
}
inline int in() {
  int x;
  std::cin >> x;
  return x;
}
template <typename T>
void print(std::vector<T>& v, char c = ' ') {
  for (int i = 0; i < v.size(); ++i) {
    if (i != 0) std::cout << c;
    std::cout << v[i];
  }
  std::cout << '\n';
}
template <typename T>
void print(T x) {
  std::cout << x << '\n';
}
signed main() {
  string str;
  cin >> str;
  string f1 = str, f2 = "";
  for (int i = 0; i < 100000; i++) {
    if (f1 == f2)
      break;
    else
      f1 = f2;
    auto pos = str.find("ST", 0);
    if (pos != string::npos) str.erase(pos, 2);
    f2 = str;
  }
  cout << str.length() << endl;
  return (0);
}
