
import sys
from collections import deque
import copy
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]

    stack = []

    for s in S:
        if len(stack) == 0:
            stack.append(s)
        else:
            if s == "T" and stack[len(stack) - 1] == "S":
                stack.pop()
            else:
                stack.append(s)
    print len(stack)


if __name__ == '__main__':
    main()
