def main():
    s = input().rstrip()
    cnt_t, cnt_s = 0, 0
    for i in range(len(s)):
        if s[i] == "S":
            cnt_t = i
            break
    for i in range(len(s)):
        if s[len(s)-1-i] == "T":
            cnt_s = i
            break
    print(2*max(cnt_t, cnt_s))

if __name__ == "__main__":
    main()