Problem:


Score : 300 points

Problem Statement

We have a string X, which has an even number of characters. Half the characters are S, and the other half are T.

Takahashi, who hates the string ST, will perform the following operation 10^{10000} times:

Among the occurrences of ST in X as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing.

Find the eventual length of X.

Constraints

2 ≦ |X| ≦ 200,000

The length of X is even.

Half the characters in X are S, and the other half are T.

Partial Scores

In test cases worth 200 points, |X| ≦ 200.

Input

The input is given from Standard Input in the following format:

X

Output

Print the eventual length of X.

Sample Input 1

TSTTSS

Sample Output 1

4

In the 1-st operation, the 2-nd and 3-rd characters of TSTTSS are removed.
X becomes TTSS, and since it does not contain ST anymore, nothing is done in the remaining 10^{10000}-1 operations.
Thus, the answer is 4.

Sample Input 2

SSTTST

Sample Output 2

0

X will eventually become an empty string: SSTTST ⇒ STST ⇒ ST ⇒ ``.

Sample Input 3

TSSTTTSS

Sample Output 3

4

X will become: TSSTTTSS ⇒ TSTTSS ⇒ TTSS.



Sample input:
TSTTSS


Sample output:
4

Submission status: Wrong Answer

Solution code:
x = raw_input()
x = x[::-1]
l = len(x)

print x.find('T')*2

Submission status: Wrong Answer

Solution code:
string = input()
stack = ""

for i in string:
    if i == "S":
        stack += i
    elif i == "T" and (stack == "" or stack[-1] == "T"):
        stack += i
    else:
        stack = stack[0:-1]
    print(stack)

print(len(stack))

Submission status: Wrong Answer

Solution code:
s = input()
# 出力
for i in range(10000):
 if "ST" in s:
  s=s[0:s.find("ST")]+s[s.find("ST")+2:-1]+s[-1]
 else:
     break
print (len(s))

Submission status: Wrong Answer

Solution code:
def AString(stringX):
    while "ST" in stringX:
        stringX = stringX.replace("ST", "", 1)
    print len(stringX)

Submission status: Wrong Answer

Solution code:
import re

def AString(stringX):
    while "ST" in stringX:
        stringX = stringX.replace("ST", "", 1)
    return len(stringX)

Submission status: Wrong Answer

Solution code:
string = list(input())

remain_len = 0

for index in range(len(string)//2):
    if string[index] == "T":
        remain_len += 2
        
print(remain_len)

Submission status: Wrong Answer

Solution code:
string = list(input())


complete_control = False
max_num = 10**10000
string_len = len(string)
while max_num: 
    temp_index = 0
    for char in range(string_len):
        if string[char] == "S" and string[char + 1] == "T":
            temp_index = char
            string_len -=2
            break
        else:
            complete_control = True
        
    del string[temp_index + 1]
    del string[temp_index]

    if complete_control:
        break
    max_num -= 1
    

print(string_len)

Submission status: Wrong Answer

Solution code:
s = input()

s = s.lstrip('ST')

print(len(s))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


if __name__ == "__main__":
    x = raw_input("")
    i = x[::-1].index("T")
    if i:
        c1= x[:-i].count("S")
        c2 = x[:-i].count("T")
        print len(x) - 2*min(c1, c2)
    else:
        print 0

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


if __name__ == "__main__":
    x = raw_input("")
    i = x[::-1].index("T")
    if i:
        c = x[:-i].count("S")
        print len(x) - 2*c
    else:
        print 0

Submission status: Wrong Answer

Solution code:

def main(s):
    return s.replace("ST","")

if __name__ == '__main__':
    cnt  = 0
    s = input()
    k = ""
    flag = False
    s= main(s)
    cnt = s.count("ST")
    if cnt != 0:
        s = main(s)
        print(len(s))
    else:
        # print(0)
        print(len(s))

Submission status: Wrong Answer

Solution code:
import sys
import string
import re
input = lambda: sys.stdin.readline()

st = []
X = input()
for x in X:
    if not len(st) == 0:
        top = st.pop()
        if top == "S" and x == "T":
            continue
        else:
            st.append(top)
            st.append(x)
    else:
        st.append(x)
print(len(st))


# st = []
# s = input()
#
# for x in s:
#     if not len(st) == 0:
#         top = st.pop()
#         # print(top)
#         if top == "S" and x == "T":
#             continue
#         else:
#             st.append(top)
#             st.append(x)
#     else:
#         st.append(x)
#
# print(len(st))

# def main(s):
#     return s.replace("ST","")
#
# if __name__ == '__main__':
#     cnt  = 0
#     s = input()
#     k = ""
#     flag = False
#     s= main(s)
#     cnt = s.count("ST")
#     if cnt != 0:
#         s = main(s)
#         print(len(s) - 1)
#     else:
#         # print(0)
#         print(len(s) - 1)

Submission status: Wrong Answer

Solution code:
import sys
import string
import re
input = lambda: sys.stdin.readline()


st = []
s = input()

for x in s:
    if not len(st) == 0:
        top = st.pop()
        # print(top)
        if top == "S" and x == "T":
            continue
        else:
            st.append(top)
            st.append(x)
    else:
        st.append(x)

print(len(st))

# def main(s):
#     return s.replace("ST","")
#
# if __name__ == '__main__':
#     cnt  = 0
#     s = input()
#     k = ""
#     flag = False
#     s= main(s)
#     cnt = s.count("ST")
#     if cnt != 0:
#         s = main(s)
#         print(len(s) - 1)
#     else:
#         # print(0)
#         print(len(s) - 1)

Submission status: Wrong Answer

Solution code:
s = input()
cnt = 0
while cnt < 100000:
    print(1)
    n = len(s)
    s = ''.join(s.split('ST'))
    if len(s) != n:
        cnt += (len(s) - n) // 2
    else:
        break
    i = s.find('ST')
    
    stlen = 0
    if i > 0:
        for j in range(min(i, len(s)-2-i)):
            if s[i-j-1] == 'S' and s[i+j+2] == 'T':
                stlen += 1
            else:
                break
        s = s[:i-stlen] + s[i+stlen+2:]
        cnt += 1 + stlen
print(len(s))

Submission status: Wrong Answer

Solution code:
s = input()
cnt = 0
while cnt < 100000:
    n = len(s)
    s = ''.join(s.split('SSSSSSSSSTTTTTTTTTT'))
    if len(s) != n:
        cnt += (len(s) - n) // 2
    n = len(s)
    s = ''.join(s.split('ST'))
    if len(s) != n:
        cnt += (len(s) - n) // 2
    else:
        break
print(len(s))

Submission status: Wrong Answer

Solution code:
s = input()
cnt = 0
while cnt < 100000:
    sp = s.split('ST', 1)
    if len(sp) > 1:
        cntlen = 0
        for i in range(min(len(sp[0]), len(sp[1]))):
            if sp[0][-1-i] == "S" and sp[1][i] == "T":
                cntlen += 1
            else:
                break
        s = sp[0][:len(sp[0])-0] + sp[1][cntlen:]
        cnt += 1 + cntlen
    else:
        break
print(len(s))

Submission status: Wrong Answer

Solution code:
s = input()
for i in range(10**10000):
    print(s)
    if 'ST' in s:
        sp = s.split('ST', 1)
        s = sp[0] + sp[1]
    else:
        break
print(s)

Submission status: Wrong Answer

Solution code:
s = input()
for i in range(10**10000):
    print(s)
    if 'st' in s:
        sp = s.split('st', 1)
        s = sp[0] + sp[1]
    else:
        break
print(s)

Submission status: Wrong Answer

Solution code:
x = str(input())
MAX = pow(10, 10000)
x = "".join(x.split("ST"))
print(len(x))

Submission status: Wrong Answer

Solution code:
import sys
import string
import re
input = lambda: sys.stdin.readline()

def main(s):
    return s.replace("ST","")

if __name__ == '__main__':
    cnt  = 0
    s = input()
    k = ""
    flag = False
    s= main(s)
    cnt = s.count("ST")
    if cnt != 0:
        s = main(s)
        print(len(s) - 1)
    else:
        # print(0)
        print(len(s) - 1)

Submission status: Wrong Answer

Solution code:
X = raw_input()

count = 0
count2 = 0
n = len(X)


for i in range(n/2):  
    if X[n-1-i] == 'S':
        count +=1
    else:
        pass
print max((count-(n/2-count))*2,0)

Submission status: Wrong Answer

Solution code:
import sys
import string
import re
input = lambda: sys.stdin.readline()

def main(s):
    return s.replace("ST","")

if __name__ == '__main__':
    cnt  = 0
    s = input()
    k = ""
    flag = False
    ans = main(s)
    cnt = ans.count("ST")
    if cnt != 0:
        k = main(ans)
        print(len(k) - 1)
    else:
        # print(0)
        print(len(ans) - 1)

Submission status: Wrong Answer

Solution code:
X = raw_input()

count = 0
count2 = 0
n = len(X)

if X[n-1] == 'S':
    for i in range(n):
    
        if X[n-1-i] == 'S':
        
            count +=1
        else:
            break
else:
    for i in range(n):
        if X[n-1-i] == 'T':
            count2 +=1
        else:
            break
    for i in range(n-count2):
        if X[n-1-i-count2] == 'S':
            count +=1
        else:
            break
print max((count-count2)*2,0)

Submission status: Wrong Answer

Solution code:
x = list(input())

before = ''
i = 0
while True:
    flag = 1
    for s in x:
        if(before == 'S' and s == 'T'):
            x.remove(x[i])
            x.remove(x[i+1])
            flag = 0
            break
        i+=1
        before = s
    if(flag == 0):
        break

print(len(x))

Submission status: Wrong Answer

Solution code:
X = input()
x = X
t = 0
s = 0
while x[0] == "T":
	t += 1
	x = x[1:]
while x[-1] == "S":
	s += 1
	x = x[:-1]
print(2*max(s,t))

Submission status: Wrong Answer

Solution code:
X = raw_input()

count = 0
n = len(X)

for i in range(n):
    
    if X[n-1-i] == 'S':
        
        count +=1
    else:
        break

print count*2

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

_input = input().split()
# _input = 'SSTTST'
s = [c for c in _input]
length = len(s)

for i, c in enumerate(s):
    if i < 1:
        continue
    elif length == i + 1:
        break

    couter = 1
    dec = i
    inc = i + couter
    try:
        while s[dec] == 'S' and s[inc] == 'T':
            del s[dec]
            del s[inc]
            couter += 1
            dec = i - couter if 0 < i - couter else 0
            inc = i + couter if length > i + couter else length - 1
    except:
        pass

print(len(s))

Submission status: Wrong Answer

Solution code:
X = raw_input('str X:')
while 'ST' in X:
    X = X.replace('ST','',1)

print len(X)

Submission status: Wrong Answer

Solution code:
s = raw_input()
t = 'ST'
while s.find(t)>-1:
    i = s.find(t)
    s = s[:i]+s[i+4:]
print len(s)

Submission status: Wrong Answer

Solution code:
X = raw_input('str X:')
while 'ST' in X:
    X = X.replace('ST','')

print len(X)

Submission status: Wrong Answer

Solution code:
X = raw_input('str X:')*(200000/6)
while 'ST' in X:
    X = X.replace('ST','')

print len(X)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# _input = input().split()
_input = 'SSTTST'
s = [c for c in _input]
length = len(s)

for i, c in enumerate(s):
    if i < 1:
        continue
    elif length == i + 1:
        break

    couter = 1
    dec = i
    inc = i + couter
    try:
        while s[dec] == 'S' and s[inc] == 'T':
            print(s)
            del s[dec]
            del s[inc]
            couter += 1
            dec = i - couter if 0 < i - couter else 0
            inc = i + couter if length > i + couter else length - 1
            print(dec)
            print(inc)
    except:
        pass

print(len(s))

Submission status: Wrong Answer

Solution code:
X = raw_input()

num_s = 0
num_t = 0
pre = ""
ans = 0
for a in X:
    if a == "S":
        if pre == "T":
            ans += min(num_s, num_t)
            num_s = 0
            num_t = 0
        num_s += 1
    elif a == "T":
        num_t += 1
    pre = a
ans += min(num_s, num_t)
print len(X) - 2*ans

Submission status: Wrong Answer

Solution code:
str = "TSTTSS"
res=len(str)
for i in range(len(str)-1):
       if str[i]=='S' and str[i+1]=='T':
              res = res - 2
print(res)

Submission status: Wrong Answer

Solution code:
from os import sys


X = input()

within_seq = False
start = -1 # start index of ST string to be removed
res = X
ST_found = False # was 'ST' ever found in the curr loop?

if len(X) < 2:
    print(0)
    sys.exit()
    
while True:
    i = 0
    while i < len(res):     
        c = res[i]    
        if not within_seq:
            if c == 'S':   
                within_seq = True
                start = i
        else:
            if c == 'S':
                start = i
            elif c == 'T':
                within_seq = True
                ST_found = True
                res = res[:start] + res[start+2:]
        i += 1

    if len(res) == 0 or not ST_found:
        break
    ST_found = False
    within_seq = False
 
print(len(res))

Submission status: Wrong Answer

Solution code:
s=list(input())

if len(s) > 200:
    exit(0)

i = 0
while i < len(s)-1:
    if s[i:i+2] == ['S','T']:
        s[i:i+2] = []
        i = max(0, i-1)
        continue
    i += 1
print(len(s))

Submission status: Wrong Answer

Solution code:
n=raw_input()
i=0
j=0
k=len(n)/3
n=list(n)
while j<k:
    if len(n)==0:
        break
    while i<len(n)-1:
        if n[i]=='S':
            if n[i+1]=='T':
                del n[i+1]
                del n[i]
        i+=1
    i=0
    j+=1

print len(n)

Submission status: Wrong Answer

Solution code:
if __name__=='__main__':
    st = input()
    i = 0
    j = i+1
    ans = 0
    while j<len(st):
        #print("aa")
        if st[i]=='S' and st[j]=='T':
            #print("haha-> ",i,j)
            ans+=1
            if i==0:
                i=j+1
                j+=2
            else:
                i-=1
                j+=1
        else:
            i+=1
            j+=1
    print(len(st)-(ans*2))

Submission status: Wrong Answer

Solution code:
s=input()
c=1 if s[0] == 'S' else 0
ans=1 if s[0] == 'T' else 0

for i in range(1, len(s)):
    if s[i] == 'S':
        if s[i-1] == 'S':
            c += 1
        else:
            ans+=c
            c=1
    else:
        if c > 0:
            c -= 1
        else:
            ans += 1
print(ans+c)

Submission status: Wrong Answer

Solution code:
a = raw_input()
b = a.find("ST")
while(b != -1):
  a = a[b:].replace("ST","")
  b = a.find("ST")
print len(a)

Submission status: Wrong Answer

Solution code:
x = input()
l = len(x)

before = l

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

print(len(x))

Submission status: Wrong Answer

Solution code:
st=raw_input()
n=len(st)
ans=0
for i in range(1,n+1):
    if st[-i]=='T':
        break
    ans+=1
ans*=2
print ans

Submission status: Wrong Answer

Solution code:
x=input()
num_t=0
num_s=0
for i in range(len(x)//2):
    if x[i]=='T':
        num_t+=1
    else:
        break
for i in range(len(x)//2):
    if x[-1-i]=='S':
        num_s+=1
    else:
        break
print(max([num_t,num_s])*2)

Submission status: Wrong Answer

Solution code:
targ = input()
length = len(targ)
num = 0
while True:
    for num in range(length):
        if targ[num: num+2] == 'ST':
            targ = targ[max(num-2,0):num] + targ[num+2:]
            length -= 2
            break
    else:
        break
print(length)

Submission status: Wrong Answer

Solution code:
s = raw_input()
while 1:
    result = s.replace("ST", "")
    if result != s:
        s = result
        break
    else: s = result
print len(s)

Submission status: Wrong Answer

Solution code:
def read():
    return int(input())

def reads(sep=None):
    return list(map(int, input().split(sep)))

def main():
    x = input()[::-1]
    i = 0
    while x[i] == 'S':
        i += 1
    print(i*2)

main()

Submission status: Wrong Answer

Solution code:
import sys                                                                                                                                                                                                                            
s = sys.stdin.readline()

i = 0
while i < len(s)-1:
        if s[i] == 'S' and s[i+1] == 'T':
                s = s[:i] + s[i+2:]
                if i > 0:
                        i -= 1
        else:
                i += 1 

print len(s)

Submission status: Wrong Answer

Solution code:
x = input()
_x = x.replace('ST', '')
print(len(_x))

Submission status: Wrong Answer

Solution code:
X = raw_input()
t = 0
a = 0
for x in X:
    if x=="T":
        t -= 1
    else:
        t += 1
    if t<0:
        a += 1
print a

Submission status: Wrong Answer

Solution code:
a = raw_input()
b = a.replace("ST","")
print len(b)

Submission status: Wrong Answer

Solution code:
X = raw_input()
X = X.replace('ST','')
print len(X)

Submission status: Time Limit Exceeded

Solution code:
s=input() ; n=len(s) ;a=""
for i in range(10000):
    s=s.replace("ST","")
    if a==s:
      print(len(s));exit()
    a=s
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
def cal():
    x = input()
    i = 0
    while i <= 2*10**3:
        i += 1
        x = x.replace('ST', '', 10**5)
    print(len(x))

cal()

Submission status: Time Limit Exceeded

Solution code:
def cal():
    x = input()
    i = 0
    while i <= 10**4:
        i += 1
        x = x.replace('ST', '', 10**5)
    print(len(x))

cal()

Submission status: Time Limit Exceeded

Solution code:
def cal():
    x = input()
    i = 0
    while i <= 10**5:
        i += 1
        x = x.replace('ST', '', 10**5)
    print(len(x))

cal()

Submission status: Time Limit Exceeded

Solution code:
def cal():
    x = input()
    i = 0
    while i <= 2*10**5:
        i += 1
        x = x.replace('ST', '', 10**5)
    print(len(x))

cal()

Submission status: Time Limit Exceeded

Solution code:
def cal():
    x = input()
    while True:
        pre = len(x)
        x = x.replace('ST', '', 10**5)
        if len(x) == pre:
            break
    print(len(x))

cal()

Submission status: Time Limit Exceeded

Solution code:
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()

Submission status: Time Limit Exceeded

Solution code:
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()

Submission status: Time Limit Exceeded

Solution code:
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()

Submission status: Time Limit Exceeded

Solution code:
import re
x = input()

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
s=input()
n=len(s)
cnt=0
while "ST" in s:
    s=s.replace("ST", "")
    cnt+=1
    #print(s)
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
X = input()

idx = 0

while idx < len(X)-1:
    if X[idx] == 'S':
        if X[idx+1] == 'T':
            X = X[:idx] + X[idx+2:]
            idx = max(-1, idx-2)
    idx += 1

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
x = input()
while 'ST' in x:
    # print(x)
    x = x.replace('ST', '')

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
X = list(input())
now = 0
while now < len(X) - 1:
    if X[now] == 'S' and X[now + 1] == 'T':
        for _ in range(2):
            X.pop(now)
        now = max(0, now - 1)
    else:
        now += 1
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
def Greedy(X):
    L=[0]
    while L:
        L=[]
        for i in range(len(X)):
            if X[i:i+2]=="ST":
                L.append(i)

        for i in L[::-1]:
            X=X[:i]+X[i+2:]

    return len(X)

X=input()
print(Greedy(X))

Submission status: Time Limit Exceeded

Solution code:
x = input()
while "ST" in x:
    x = x.replace("ST", "")
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
X = input()

while X != ''.join(X.split('ST')):
    X = ''.join(X.split('ST'))

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    t = s

    while True:
        s = s.replace('ST', '')

        if s == t:
            print(len(s))
            exit()

        t = s


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
X=input()

for i in range(int(len(X)/2)):
    s=X.find('ST')
    if s==-1:
        break
    else:
        X=X[:s]+X[s+2:]

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
def main():
    x = input()
    tmp = x.replace("ST", "")
    for i in range(10**6):
        if x == tmp:
            break
        x = tmp
        tmp = tmp.replace("ST", "")
    print(len(x))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    x = input()
    tmp = x.replace("ST", "")
    while x != tmp:
        x = tmp
        tmp = tmp.replace("ST", "")
    print(len(x))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
x = input()

def test(x):
    x2 = [i for i in x]
    while True:
        flag = True
        n = len(x2)
        for i in range(n - 1):
            if x2[i] == "S" and x2[i + 1] == "T":
                flag = False
                x2.pop(i)
                x2.pop(i)
                break
        if flag:
            break
    return len(x2)

print(test(x))

# def main(x): 
#     s_cnt = 0
#     t_cnt = 0
#     n = len(x)
#     ans = n
#     for i in range(n):
#         if i == 0:
#             if x[i] == "S":
#                 s_cnt += 1
#             continue
#         if x[i] == "S":
#             if x[i - 1] == "T":
#                 ans -= min(s_cnt, t_cnt) * 2
#                 s_cnt = 1
#                 t_cnt = 0
#             else:
#                 s_cnt += 1
#         else:
#             t_cnt += 1
#     ans -= min(s_cnt, t_cnt) * 2
#     # print(ans)
#     return ans

# for i in range(1 << 10):
#     bit = bin(i)[2:].zfill(10)
#     x = ""
#     for j in range(10):
#         if bit[j] == "1":
#             x += "S"
#         else:
#             x += "T"
#     ans_main = main(x)
#     ans_test = test(x)
#     if ans_main != ans_test:
#         print(x)
#         print(ans_main)
#         print(ans_test)
#         # print("error")
#         break

Submission status: Time Limit Exceeded

Solution code:
X = input()
X_ = ''
while X!=X_:
    X_ = X
    X = X.replace('ST', '')
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
x = input()
while 'ST' in x:
    x = x.replace('ST', '')
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
# AGC005A

# TLE 2/13
x = input()
while 'ST' in x:
    x = x.replace('ST', '', 1)
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
# AGC005A

x = input()
while 'ST' in x:
    x = x.replace('ST', '', 1)
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
s = input()
n = len(s)
i = 0
while i < n-1:
     if s[i: i + 2] == "ST":
          s = s[:i] + s[i + 2 :]
          i = 0
          n -= 2
          continue
     i += 1
print(n)

Submission status: Time Limit Exceeded

Solution code:
x=input()

for _ in range(10**5):
    x=x.replace('ST','')

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
x=input()

for _ in range(10**6):
    x=x.replace('ST','')

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
s = input()

while s.count("ST")>0:
      s = s.replace("ST","")
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
def main():
    X=input()
    a=X
    while 'ST' in a:
        a=a.replace('ST','',int(1e5))
    print(len(a))
main()

Submission status: Time Limit Exceeded

Solution code:
X=input()
a=X
while 'ST' in a:
    a=a.replace('ST','',int(1e5))
print(len(a))

Submission status: Time Limit Exceeded

Solution code:
X=input()
a=X
while 'ST' in a:
    a=a.replace('ST','',100)
print(len(a))

Submission status: Time Limit Exceeded

Solution code:
X=input()
a=X
while 'ST' in a:
    a=a.replace('ST','',1)
print(len(a))

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    import re
    x = input()
    while "ST" in x:
        x = re.sub("ST", "", x)
    print(len(x))
resolve()

Submission status: Time Limit Exceeded

Solution code:
# 5

s = input()
n = 0

while len(s) >= 0:
    if not('ST' in s):
        break
    else:
        s = s.replace('ST', '')
        #print(s)

print(len(s))
#print(s)

Submission status: Time Limit Exceeded

Solution code:
x = input()
while "ST" in x:
  x=x.replace("ST","")
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
X = str(input())

for i in range (0, int(len(X)/2)+1):
	X = X.replace("ST", '')
	if X == X.replace("ST", ''):
		print(len(X))
		exit() 

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()

for i in range (0, 100001):
	X = X.replace("ST", '')
	if X == X.replace("ST", ''):
		print(len(X))
		exit() 

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()

for i in range (0, 100001):
	X = X.replace("ST", '')

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
n = list(input())
i = 0
while True:
    if n[i:i+2] == ["S",'T']:
        n[i:i+2] = ""
        i = 0
    else:
        i += 1
    if i == len(n)-1 or len(n) == 0:
        break
print(len(n))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(X: str):
    next = X.replace("ST", "")
    while next != X:
        X = next
        next = X.replace("ST", "")
    print(len(X))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = next(tokens)  # type: str
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(X: str):
    i = X.find("ST")
    while i >= 0:
        X = X[:i] + X[i+2:]
        i = X.find("ST")
    print(len(X))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = next(tokens)  # type: str
    solve(X)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
S = input()
for _ in range(200000):
    S = S.replace('ST','')
print(len(S))

Submission status: Time Limit Exceeded

Solution code:
x = input()

length = len(x)
while True:
    x = x.replace("ST", "")
    if len(x) == length:
        break
    else:
        length = len(x)

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
X = input()
Index = 0
for j in range(pow(10,10000)):
    if len(X) <= Index + 1 :
        break
    else:
        if X[Index:Index+2] == 'ST':
            if Index > 0:
                X = X[0:Index] + X[Index + 2:len(X)]
                Index -= 1
                continue
            else:
                X =  X[Index + 2:len(X)]
                continue
    Index +=1
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()
Index = 0
for j in range(pow(10,10000)):
    if len(X) <= Index + 1 :
        break
    else:
        if X.find('ST',Index,Index+2) >= 0:
            if Index > 0:
                X = X[0:Index] + X[Index + 2:len(X)]
                Index -= 1
                continue
            else:
                X =  X[Index + 2:len(X)]
                continue
    Index +=1
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()
rep = X.replace("ST", "")
while X != rep:
    X = rep
    rep = X.replace("ST", "")
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10 ** 15
mod = 10 ** 9 + 7
s = input()
n = len(s)
# 区間DP ダルマ落とし
dp = [[0 for j in range(n)]for i in range(n)] # iからjまで崩せる最大値 (0オリジン)
for k in range(1,n):  # 区間長1からn-1
    for i in range(0,n-k):  # i が区間の始まり   i+k が区間の終わり
        # 両端が揃ったら消せる かつ 間が全部消えるなら
        if s[i] == 'S' and s[i+k] == 'T' and dp[i+1][i+k-1] == k-1:
            dp[i][i+k] = dp[i+1][i+k-1] + 2
        else:
            # i+j が区間を区切るところ(i+jは左側に含まれる)  | i ~ i+j  |  i+j+1 ~ i+k | で考えてる。
            # 今回は今回はダルマを崩す順番の問題
            for j in range(k):
                dp[i][i+k] = max(dp[i][i+k], dp[i][i+j] + dp[i+j+1][i+k])
print(n-dp[0][n-1])

Submission status: Time Limit Exceeded

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	s = list(input())[:-1]

	p=''
	pi=-1
	is_exist_st=False
	#pa(s)
	for i, c in enumerate(s):
		if p == 'S' and c == 'T':
			s[pi] = 'e'
			s[i] = 'e'
			#print(s)
			is_exist_st = True
			p=''
			for bj in range(i):
				if s[i-1-bj]!='e':
					p=s[i-1-bj]
					pi=i-1-bj
					break
		else:
			p=c
			pi=i
	return len(s)-s.count('e')
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Time Limit Exceeded

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=1
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	s = list(input())[:-1]
	while True:
		p=''
		pi=-1
		is_exist_st=False
		#pa(s)
		for i, c in enumerate(s):
			if p == 'S' and c == 'T':
				s[pi] = 'e'
				s[i] = 'e'
				#print(s)
				is_exist_st = True
				p=''
				for bj in range(i):
					if s[i-1-bj]!='e':
						p=s[i-1-bj]
						pi=i-1-bj
						break
				
			elif c == 'e':
				pass
			else:
				p=c
				pi=i
		
		if not is_exist_st:
			break	
	return len(s)-s.count('e')
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)