def main():
    X = input()
    s, t = 0, 0
    for x in X:
        if x == "S":
            s += 1
        else:
             t += 1
    for x in X:
        if x == "T":
            t -= 1
        else:
            break
    for x in X[::-1]:
        if x == "S":
            s -= 1
        else:
            break
    print(len(X) - min(s, t) * 2)
main()