Buggy python submission (verdict: Time Limit Exceeded):
def cal():
    x = input()
    i = 0
    while i <= 2*10**3:
        i += 1
        x = x.replace('ST', '', 10**5)
    print(len(x))

cal()


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
def cal():
    x = input()
    i = 0
    while i <= 10**4:
        i += 1
        x = x.replace('ST', '', 10**5)
    print(len(x))

cal()


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
def cal():
    x = input()
    i = 0
    while i <= 10**5:
        i += 1
        x = x.replace('ST', '', 10**5)
    print(len(x))

cal()


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
def cal():
    x = input()
    i = 0
    while i <= 2*10**5:
        i += 1
        x = x.replace('ST', '', 10**5)
    print(len(x))

cal()


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
def cal():
    x = input()
    while True:
        pre = len(x)
        x = x.replace('ST', '', 10**5)
        if len(x) == pre:
            break
    print(len(x))

cal()


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import re
def cal():
    x = input()
    a = re.compile('ST')
    while True:
        pre = len(x)
        x = a.sub('', x)
        if len(x) == pre:
            break
    print(len(x))

cal()


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import re

def cal():
    x = input()
    while True:
        pre = len(x)
        x = re.sub('SSTT', '', x)
        x = re.sub('ST', '', x)
        if len(x) == pre:
            break
    print(len(x))

cal()


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import re

def cal():
    x = input()
    while True:
        pre = len(x)
        x = re.sub('ST', '', x)
        if len(x) == pre:
            break
    print(len(x))

cal()


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import re
x = input()

while True:
    pre = len(x)
    x = re.sub('ST', '', x)
    if len(x) == pre:
        break
print(len(x))


Fixed submission:
x = input()
ans = []

for i in x:
    if i == 'S':
        ans.append(i)
    else:
        if len(ans) == 0 or ans[-1] == 'T':
            ans.append(i)
        else:
            ans.pop()
print(len(ans))