import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    X = input()
    i = 0
    while X[i] != 'S': i += 1
    a = X[i:len(X)].count('T')
    X = X[::-1]
    i = 0
    while X[i] != 'T': i += 1
    b = X[i:len(X)].count('S')
    print(len(X)-2*min(a, b))

    return

if __name__ == '__main__':
    main()
