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


def main():
    s = input()
    t = s

    while True:
        s = s.replace('ST', '')

        if s == t:
            print(len(s))
            exit()

        t = s


if __name__ == '__main__':
    main()
