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