import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    x = input().strip()
    tc = 0
    sc = 0
    for c in x[::-1]:
        if c == 'S':
            sc += 1
        else:
            break
    for c in x:
        if c == 'T':
            tc += 1
        else:
            break
    print(max(sc, tc) * 2)


if __name__ == '__main__':
    main()
