s = str(input())
n = len(s)

flag = False
C = 0
X = []
for i in range(n):
    if not flag:
        if s[i] == 'S':
            C = i
            flag =True
            cur = s[i]
            cnt = 1
    else:
        if s[i] != cur:
            X.append(cnt)
            cnt = 1
            cur = s[i]
        else:
            cnt += 1
else:
    X.append(cnt)
#print(C)
#print(X)
r = 0
for i in range(len(X)):
    if i%2 == 0:
        if i+1 <= len(X)-1:
            r += min(X[i], X[i+1])*2
print(n-r)
