w = input()

mode = 1
c_s = 0
ans = 0

for i in w:
#    print(i)
    if i == 'S':
        if mode == 0:
            c_s += 1
#            print(ans,mode,c_s)
#            print('a')
        elif mode == 1:
            c_s = 1
            mode = 0
#            print(ans,mode,c_s)
#            print('b')
    else:
        if mode == 0:
            ans += 1
            mode = 1
            c_s -= 1
#            print(ans,mode,c_s)
#            print('c')
        elif mode == 1 and c_s > 0:
            ans += 1
            c_s -= 1
#            print(ans,mode,c_s)
#            print('d')

print(len(w)-(2*ans))
