# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())

    t_count, s_count = 0, 0
    while s[t_count] == "T":
        t_count += 1
    while s[-(s_count+1)] == "S":
        s_count += 1

    print(max(t_count, s_count) * 2)


if __name__ == "__main__":
    main()
