# -*- coding: utf-8 -*-
from __future__ import unicode_literals


if __name__ == "__main__":
    x = raw_input("")
    i = x[::-1].index("T")
    if i:
        c = x[:-i].count("S")
        print len(x) - 2*c
    else:
        print 0
