Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

x = input()

frag = True
while frag:
    frag = False
    if x[0: 2] == "ST":
        x = x[2:]
        frag = True
        continue
    for i in range(1, len(x)):
        if x[i: i+2] == "ST":
            x = x[0: i] + x[i+2:]
            frag = True
            break

print(len(x))


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

x = input()

frag = True
while frag:
    frag = False
    if x[0: 2] == "ST":
        x = x[2:]
        frag = True
        continue
    for i in range(1, len(x)):
        if x[i: i+2] == "ST":
            x = x[0: i] + x[i+2:]
            frag = True
            break

print(len(x))


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

x = input()

frag = True
while frag:
    frag = False
    if x[0: 2] == "ST":
        x = x[2:]
        frag = True
        continue
    for i in range(1, len(x)):
        if x[i: i+2] == "ST":
            x = x[0: i] + x[i+2:]
            frag = True
            break

print(len(x))


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

x = input()

for i in range(0, 100000):
    x = x.replace("ST", "")
    if len(x) == 0:
        break

print(len(x))


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

x = input()

for i in range(0, int(len(x)/2)):
    x = x.replace("ST", "")
    if len(x) == 0:
        break

print(len(x))


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

x = input()

for i in range(0, int(len(x)/2)):
    x = x.replace("ST", "")

print(len(x))


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

x = input()

for i in range(0, int(len(x)/2)):
    if "ST" in x:
        x = x.replace("ST", "")
    else:
        break

print(len(x))


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

x = input()

for i in range(0, pow(10, 10000)):
    if "ST" in x:
        x = x.replace("ST", "")
    else:
        break

print(len(x))


Fixed submission:
# -*- coding: utf-8 -*-

x = input()

# ペアになっていないSの数（ペアができたら-1）
sc = 0
# ペアにならなかったTの数
tc = 0

for c in x:
    if c == 'S':
        sc += 1
    elif sc >= 1:
        sc -= 1
    else:
        tc += 1

print(sc + tc)