from bisect import bisect_right

def cal(X):
    S,T = [],[]
    for i in range(len(X)):
        if X[i] == "S":
            S.append(i)
        else:
            T.append(i)

    pt = bisect_right(S,T[len(T)-1])
    return 2*(len(S)-pt)

def main():
    X = input()
    print(cal(X))

if __name__ == "__main__":
    main()
