#include <bits/stdc++.h>
#include <regex>

using namespace std;
template<typename T> void in(T &x) { x = 0; bool neg = false; register T c = getchar(); if (c == '-')neg = true, c = getchar(); while ((c < 48) || (c > 57))c = getchar(); for (; c < 48 || c > 57; c = getchar()); for (; c > 47 && c < 58; c = getchar())x = (x << 3) + (x << 1) + (c & 15); if (neg) x *= -1; }
template<typename T> void out(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); }
template<typename T> void outln(T n) { bool neg = 0; if (n < 0)n *= -1, neg = 1; char snum[65]; int i = 0; do { snum[i++] = n % 10 + '0'; n /= 10; } while (n); --i; if (neg)putchar('-'); while (i >= 0)putchar(snum[i--]); putchar('\n'); }
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define fastIO ios_base::sync_with_stdio(false); cin.tie(false);
#define ll long long
#define itr(_c) for(auto i=_c.begin();i!=_c.end();i++)
#define itrr(_c)for(auto i=_c.begin();i!=_c.end();i++)
#define f1(_x)for (int i = 0; i < _x; ++i)
#define fr(_x)for (int i = _x; i >0; i--)
#define f2(_x,_y)for (int i = _x; i < _y; ++i)
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
typedef vector<int> vi; typedef vector<string> vs; typedef vector<bool> vb; vector<long long>vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;

int main() {fastIO
	string s;
	std::cin >> s;
	while(int n=(s.find("ST")!=s.npos))
	{
		s.erase(s.begin() + n -1, s.begin() + n + 1);
	}

	std::cout << s.size();
	
	
}
