import sys
input = sys.stdin.readline

def main():
    x = input().strip() + "x"
    c = []
    pre = x[0]
    count = 1
    for i in range(1, len(x)):
        if x[i] != pre:
            c.append(count)
            count = 1
        else:
            count += 1
        pre = x[i]

    ans = len(x) - 1
    if x[0] == "S":
        for i in range(1, len(c), 2):
            ans -= min(c[i-1], c[i]) * 2
    else:
        for i in range(2, len(c), 2):
            ans -= min(c[i-1], c[i]) * 2
    print(ans)




if __name__ == "__main__":
    main()