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: Time Limit Exceeded

Solution code:
X = list(input())

i = 0
check = 0

while check == 0 :
    if i == len(X) - 1 or i == len(X):
        check = 1
    else:
        #print(i, X)
        if X[i] == 'S' and X[i+1] == 'T':
            X.pop(i)
            X.pop(i)
            i = max(0, i-1)
        else:
            i += 1
        
    
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
s = input()
stop = 0
while stop == 0:
    ls = list(s)
    for i in range(len(ls)-1):
        if ls[i] == "S" and ls[i+1] == "T":
            ls[i], ls[i+1] = "", ""
    new_s = "".join(ls)
    if s == new_s:
        stop = 1
    else:
        s = new_s 
print(len(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 = input()
y = len(x) +1
while len(x)<y:
    y = len(x)
    x = x.replace("ST","")
print(len(x))

Submission status: Time Limit Exceeded

Solution code:

def main():
    data = input()

    while 'ST' in data:
        data = data.replace('ST', '')
    print(len(data))




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
S = input()
lenS = len(S)
index = 0
ans = lenS
while index < lenS-1:
    if S[index:index+2] == "ST":
        S = S[:index] + S[index+2:]
        ans -= 2
        index -= 1
    else:
        index += 1
print(str(ans))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

X = input()
num = pow(10, 100000)
ctr = 0

for i in range(num):
    if 'ST' in X:
        X = X.replace('ST', '')
    else:
        break
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

X = input()
num = pow(10, 100000)
ctr = 0

for i in range(num):
    if 'ST' in X:
        X = X.replace('ST', '', 1)
    else:
        break
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
#AGC005
s = input()
nost = False
while not nost:
    if len(s) == 0:
        nost = True
    else:
        prev = s[0]
        for i in range(1, len(s)):
            nost = True
            if prev == 'S' and s[i] == 'T':
                nost = False
                s = s[:i-1] + s[i+1:]
                break
            prev = s[i]
        
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
x = input()
for i in range(2*10**5):
    if 'ST' not in x:
        break
    x = x.replace('ST', '')
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
X = input()

while X.count("ST"):
    X = X.replace("ST", "")

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

X = input()

count = 0
while count < 10**10000:
    tmp = ""
    i = 0
    flag = 0
    while i < len(X)-1:
        if X[i]+X[i+1] == "ST":
            if i == len(X)-2:
                flag = 1
                break
            i += 2
        else:
            tmp += X[i]
            i += 1
    if flag == 0:
        if len(X)!=0:
            tmp += X[len(X)-1]

    if len(X)==len(tmp):
        break
    else:
        X = tmp
        count += 1
print(len(X))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
X = (stdin.readline().rstrip())
for i in range(10**6):
    X = X.replace("ST","")
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
x=input()
while "S"*10+"T"*10 in x:x=x.replace("S"*10+"T"*10,"")
while "ST" in x:x=x.replace("ST","")
print(len(x))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x=input()
while "SSTT" in x:x=x.replace("SSTT","")
while "ST" in 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:
X = input()
while True:
	i = X.find('ST')
	if i == -1:
		break
	else:
		X = X[:i] + X[i+2:]
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
x = input()

while x.find('ST') != -1:
    x = x.replace('ST', '')

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
x = input()
while (len(x.split("ST")) > 1):
    x = "".join(x.split("ST"))
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
s = input()
while True:
  l = len(s)
  s = s.replace('ST', '', 1)
  if l == len(s):
    break
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()
while True:
  l = len(s)
  s = s.replace('ST', '')
  if l == len(s):
    break
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()
n = len(s)
i = 0
while i < n-1:
    if s[i] == "S" and s[i+1] == "T":
        s = s[:i] + s[i+2:]
        i = 0
        n -= 2
    else:
        i += 1

print(n)

Submission status: Time Limit Exceeded

Solution code:
X = input()
for _ in range(len(X)//2):
  X = X.replace('ST','')

print(len(X))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python

s = raw_input()

s1 = []
for x in s:
	if not s1:
		s1.append(x)
		continue
	if x == 'T' and s1[-1] == 'S':
		s1 = s1[:-1]
	else:
		s1.append(x)

print len(s1)

Submission status: Time Limit Exceeded

Solution code:
s = raw_input()
a = s.replace("ST","")
a2 = a.replace("ST", "")
while len(a) != len(a2):
	a = a2
	a2 = a2.replace("ST", "")
print len(a2)

Submission status: Time Limit Exceeded

Solution code:
s = raw_input()

head = []
sub = 0

for i, v in enumerate(s):
    if v == 'S':
        head.append(i)

    if v == 'T' and head:
        head.pop(0)
        sub += 2

print(len(s) - sub)

Submission status: Time Limit Exceeded

Solution code:
X = list(input())

delete = True
while delete:
    delete = False
    for i in range(len(X)-1):
        if X[i] == 'S' and X[i+1] == 'T':
            delete = True
            del X[i:i+2]
            break
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
s=input()
f=''
while True:
  s=s.replace('ST','',1)
  if f==s: break
  f=s
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = list(str(input()))
while True:
    cns = len(s)
    cnt = 0
    for i in range(cns):
        try:
            a = s[i]
            b = s[i+1]
            if a == "S" and b == "T":
                del s[i:i+2]
                cnt -= 1
        except:
            pass
    if cnt == 0:
        print(len(s))
        exit()

Submission status: Time Limit Exceeded

Solution code:
s = str(input())
s = [s[i] for i in range(len(s))]
while True:
    cns = len(s)
    cnt = 0
    for i in range(cns):
        try:
            a = s[i]
            b = s[i+1]
            if a == "S" and b == "T":
                del s[i:i+2]
                cnt -= 1
        except:
            pass
    if cnt == 0:
        print(len(s))
        exit()

Submission status: Time Limit Exceeded

Solution code:
S = input()

tmp = len(S)
while True:
  S = S.replace("ST", "")
  if(len(S) == tmp):
    break
  tmp = len(S)
print(len(S))

Submission status: Time Limit Exceeded

Solution code:
X = input()
lenX = len(X)
cnt = 0
for i in range(lenX // 2):
    if 'ST' in X:
        idx = X.index('ST')
        X = X[: idx] + X[idx + 2 :]
        cnt += 2
print(lenX - cnt)

Submission status: Time Limit Exceeded

Solution code:
def solve():
  s =input()
  n =len(s)
  #Tの位置とSの位置がほしい
  places = []
  placet = []
  for i in range(n):
    if s[i] == 'S':places.append(i)
    else: placet.append(i)
  places = places[::-1]
  placet = placet[::-1]
  ct = 0
  for j in places:
    if j < placet[0]:
      ct += 2
      placet.pop(0)
  return (n-ct)  
  
  
if __name__ == '__main__':
  print(solve())

Submission status: Time Limit Exceeded

Solution code:
x=input()
judge = True
while judge:
    for i in range(len(x)):
        if x[i:i+2] == "ST" :
            x=x[:i] + x[i+2:]
            break
    if "ST" not in x : 
        judge=False
        print(len(x))

Submission status: Time Limit Exceeded

Solution code:
s=input()
while True:
  if s.count("ST")==0:break
  s=s.replace("ST","")
print(len(s))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
X = input()
for i in range(len(X)//2+1):
    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:
# -*- 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))

Submission status: Time Limit Exceeded

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

x = input()

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

print(len(x))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x = input()

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

print(len(x))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
s = input()
n = len(s)

while s != "":
    for i in range(n):
        if i == n-1:
            print(n)
            exit()
        if s[i]+s[i+1] == "ST":
            s = s[:i] + s[i+2:]
            n = len(s)
            break

print(0)

Submission status: Time Limit Exceeded

Solution code:
s = str(input())
s = [s[i] for i in range(len(s))]
while True:
    cns = len(s)
    cnt = 0
    for i in range(cns):
        try:
            a = s[i]
            b = s[i+1]
            if a == "S" and b == "T":
                del s[i:i+2]
                cnt -= 1
        except:
            pass
    if cnt == 0:
        print(len(s))
        exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
X = input()

flag = True
while flag:
    flag = False
    i = 0
    while i < len(X):
        if X[i:i+2] == "ST":
            X = X[:i]+X[i+2:]
            flag = True
        else:
            i += 1

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
x=input()
y=[]
for i in range(len(x)):
  if(x[i]=="S"):y=y+[0]
  else:
    if(len(y)>0 and y[-1]==0):y.pop(-1)
    else:y=y+[1]
print(len(y))

Submission status: Time Limit Exceeded

Solution code:
x=input()
i=0
while(i<len(x)):
  if(x[i:i+2]=="ST"):
    x=x[:i]+x[i+2:]
    i=max(i-2,0)
  else:i+=1
print(len(x))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import re

text = input()
pattern = 'ST'

while True:
    if pattern in text:
        splt_txt = re.split(pattern, text)
        text = ''.join(splt_txt)
    else:
        break

print(len(text))

Submission status: Time Limit Exceeded

Solution code:
X = input()

for _ in range(len(X)//2):
    X = X.replace('ST', '')

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()

for _ in range(len(X)):
    X = X.replace('ST', '')

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
#
# A - STring
#
# input
x_before = input()
x_after = ''
# calc
while True:
  x_after = x_before.replace('ST', '')
  if len(x_before) == len(x_after):
    break
  x_before = x_after
# output
print(len(x_after))

Submission status: Time Limit Exceeded

Solution code:
X = input()

while True:
    length = len(X)
    isST = True
    for i in range(length-1):
        if X[i] == "S" and X[i+1] == "T":
            X = X[:i] + X[i+1+1:]
            break
        else:
            continue
        
    if "ST" not in X:
        break
        
    

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
x=str(input())
while "ST" in x:
    x.strip("ST")
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
X = input()
if len(X) >= 15 **5:
    for i in range(len(X)):
        if X[i] == "S":
            count_T = X[i:].count("T")
            break
    for i in range(len(X)-1,-1,-1):
        if X[i] == "T":
            count_S = X[:i+1].count("S")
            break
    pair = min(count_T,count_S)
    ans = len(X) - 2 * pair
    print(ans)
else:
    for i in range(10**5):
        note = X
        X = X.replace("ST","")
        if note == X:
            break
    print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()
def erase(string,word):
    for i in range(10**5):
        note = string
        string = string.replace(word,"")
        if note == string:
            break
    return string
for e in ["SSSSTTTT","SSSTTT","SSTT","ST"]:
    X = erase(X,e)
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()
X = X.replace("ST","")
if X[:len(X) // 2].count("S") == len(X) // 2:
    print(0)
    exit()
for i in range(10**5):
    note = X
    X = X.replace("ST","")
    if note == X:
        break
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()
if X[:len(X) // 2].count("S") == len(X) // 2:
    print(0)
    exit()
for i in range(10**5):
    note = X
    X = X.replace("ST","")
    if note == X:
        break
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()
for i in range(10**5):
    note = X
    X = X.replace("ST","")
    if note == X:
        break
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()
for i in range(10**5):
    X = X.replace("ST","")
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
X = input()
tmp = ""
for x in X:
    tmp += x
    tmp = tmp.replace("ST","")
print(len(tmp))

Submission status: Time Limit Exceeded

Solution code:
X = input()
N = len(X)//2
for _ in range(N):
    X = X.replace("ST", "")
print(len(X))

Submission status: Time Limit Exceeded

Solution code:
_x = input()
x = []
for i in _x:
    x.append(i)
count = 0
i = 0
while i < len(x):
    # print("i:{} x:{}".format(i, x))
    if i < len(x) - 1 and x[i] == "S" and x[i + 1] == "T":
        del x[i]
        del x[i]
        if i > 0:
            i -= 1
        continue
    else:
        count += 1
        i += 1
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
x=input()
ans=len(x)
while 1:
    x=x.replace("ST","")
    if len(x)==ans: break
    ans=len(x)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = input()
a = []
for i in s:
  a.append(i)
  if len(a) >= 2 and a[-1] == "T" and a[-2] == "S":
    a = a[:-2]
print(len(a))

Submission status: Time Limit Exceeded

Solution code:
s=input()

i=0
while i<len(s):
    if s[i:i+2]=="ST":
        s = s[:i] + s[i+2:]
        i -= 1
    else:
        i += 1
        
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
a = input()
b = list(a)
st = "ST"

for i in range(10000):
  c = a.find(st)
  if c != -1:
    b.pop(c)
    b.pop(c)
    a = "".join(b)
  else:
    break
    
print(len(a))

Submission status: Time Limit Exceeded

Solution code:
a = input()
b = list(a)
st = "ST"

for i in range(100000):
  c = a.find(st)
  if c != -1:
    b.pop(c)
    b.pop(c)
    a = "".join(b)
  else:
    break
    
print(len(a))

Submission status: Time Limit Exceeded

Solution code:
import sys
x=input()
tmp=x.split("ST")
tmp=''.join(tmp)
a=len(tmp)
for i in range(100000):
    tmp=tmp.split("ST")
    tmp=''.join(tmp)
    if len(tmp)==a:
        print(len(tmp))
        break
    elif len(tmp)==0:
        print(0)
        break
    else:
        a=len(tmp)

Submission status: Time Limit Exceeded

Solution code:
import sys
x=input()
tmp=x.split("ST")
tmp=''.join(tmp)
a=len(tmp)
for i in range(2000000):
    tmp=tmp.split("ST")
    tmp=''.join(tmp)
    if len(tmp)==a:
        print(len(tmp))
        break
    elif len(tmp)==0:
        print(0)
        break
    else:
        a=len(tmp)

Submission status: Time Limit Exceeded

Solution code:
X = input()

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

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
x = input()
while True:
    if "ST" in x:
        i = x.index("ST")
        x = x[:i] + x[i+2:]
    else:
        print(len(x))
        exit()

Submission status: Time Limit Exceeded

Solution code:
stL = list(input())

if len(stL)==1:
    print(1)
else:
    flag=1
    beforeC=""
    while flag:
        flag=0
        index=0
        while index < len(stL):
            if index==0:
                beforeC = stL[index]
            else:
                if beforeC=="S" and stL[index]=="T":
                    del stL[index-1]
                    del stL[index-1]
                    flag=1
                    break
                else:
                    beforeC = stL[index]
            index+=1
    print(len(stL))

Submission status: Time Limit Exceeded

Solution code:
stL = list(input())

flag=1
beforeC=""
while flag:
    flag=0
    index=0
    while index < len(stL):
        if index==0:
            beforeC = stL[index]
        else:
            if beforeC=="S" and stL[index]=="T":
                del stL[index-1]
                del stL[index-1]
                flag=1
                break
            else:
                beforeC = stL[index]
        index+=1
print(len(stL))

Submission status: Time Limit Exceeded

Solution code:
s = input()

for _ in range(int(len(s)/2)):
    s = s.replace('ST', '')
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()

for _ in range(100000):
    s = s.replace('ST', '')
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()

for _ in range(100000):
    s = s.replace('ST', '', 1)
print(len(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 = input()
while "ST" in x:
  x.replace("ST","")
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
S = input()
ans = len(S)
while 'ST' in S:
    num = S.count('ST')
    S = S.replace('ST','',num)


print(len(S))

Submission status: Time Limit Exceeded

Solution code:
S = input()
ans = len(S)
while 'ST' in S:
    S = S.replace('ST','')


print(len(S))

Submission status: Time Limit Exceeded

Solution code:
S = 1
for c in input():
    if c == 'S':
        S = S << 1 | 1
    else:
        if S > 1 and S & 1:
            S >>= 1
        else:
            S = S << 1 | 0
print(len(bin(S)) - 3)

Submission status: Time Limit Exceeded

Solution code:
s = input()
while s.find('ST')!=-1:
    s = s.replace('SSTT','')
    s = s.replace('ST','')
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()
while s.find('ST')!=-1:
    s = s.replace('ST','')
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()
while s.find('ST')!=-1:
    s = s.replace('ST','',1)
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x=arr_data[0][0]

while "ST" in x:
    
   x=x.replace("ST","")

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x=arr_data[0][0]

cnt=10**10000
for i in range(cnt):
    
    if "ST" in x:
        
        x=x.replace("ST","")

    else:
        break

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
import re

def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x=arr_data[0][0]


pattern="ST"


cnt=10**10000
for i in range(cnt):
    
    if "ST" in x:

        x = re.sub(pattern, "", x)
    else:
        
        break
        
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
import re

def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x=arr_data[0][0]


pattern="ST"


cnt=10**10000
for i in range(cnt):
    
    if x.count("ST")>0:

        x = re.sub(pattern, "", x)
    else:
        
        break
        
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x=arr_data[0][0]


#while x.count("ST")>0:
#    
#   x=x.replace("ST","")

cnt=10**10000
for i in range(cnt):
    
    if x.count("ST")>0:
        
        x=x.replace("ST","")

    else:
        break

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:
def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x=arr_data[0][0]


while x.count("ST")>0:
    
   x=x.replace("ST","")

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

x=arr_data[0][0]

cnt=10**10000

for i in range(cnt):

    if x.find("ST")>=0:
        
        x=x.replace("ST","",1)
        
    else:
        
        break
        
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
def main():
    X = input()

    ans = part(X)
    print(ans)


def test_ans():
    X_ans = [
        ("TSTTSS", 4),
        ("SSTTST", 0),
        ("TSSTTTSS", 4),
    ]
    for X, ans in X_ans:
        assert part(X) == editorial(X) == ans


def editorial(X):
    stack = [X[0]]
    ans = len(X)
    for c in X[1:]:
        if stack and stack[-1] == "S" and c == "T":
            ans -= 2
            stack.pop()
        else:
            stack.append(c)

    return ans


def part(X):
    while True:
        n = len(X)
        for i in range(n-1):
            if X[i:i+2] == "ST":
                X = X[:i] + X[i+2:]
                break

        if n == len(X):
            break

    return len(X)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    X = input()

    ans = part(X)
    print(ans)


def part(X):
    while True:
        n = len(X)
        for i in range(n-1):
            if X[i:i+2] == "ST":
                X = X[:i] + X[i+2:]
                break

        if n == len(X):
            break

    return len(X)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    x = input()

    while 'ST' in x:
        x = x.replace('ST', '')

    print(len(x))

Submission status: Time Limit Exceeded

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

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    x = input()

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

    print(len(x))

Submission status: Time Limit Exceeded

Solution code:
s = input()
import re
while(s != re.sub("ST", "", s)):
    s = re.sub("ST", "", s)
print(len(s))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
s = input()
while(s != s.replace("ST", "", 1)):
    s = s.replace("ST", "", 1)
print(len(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 = input()

while(True):
    temp = X.replace("ST","")
    if len(X)==len(temp):break
    X = temp
    
print(len(X))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
x=input()
if "ST" in x:
    x=x.replace("ST","")
for i in range(len(x)//2):
    x=x.replace("ST","")
print(len(x))

Submission status: Time Limit Exceeded

Solution code:
x = list(input())

L = len(x)
now = len(x) - 1
while now >= 0 and L >= 2 :
    if now == L - 1 :
        now -= 1
        continue
    if x[now] == 'S' and x[now+1] == 'T' :
        x.pop(now+1)
        x.pop(now)
        L -= 2
    now -= 1

print(len(x))

Submission status: Time Limit Exceeded

Solution code:
x=input().replace("ST","")
for _ in range(100000):
    if "ST" in x:
        x=x.replace("ST","")
print(len(x))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
X = input()
S = len(X)
while(True):
    N = len(X)
    X = X.replace("ST", "")
    K = N - len(X)
    if K == 0:
        break
    else:
        S -= K
print(S)

Submission status: Time Limit Exceeded

Solution code:
X=input()

for i in range(len(X)):
    if "ST" in X:
        X=X.replace("ST","")
    else:
        break

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X=input()

for i in range(len(X)):
    if "ST" in X:
        X=X.replace("ST","",1)
    else:
        break

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X=input()

t=len(X)

for i in range(len(X)):
    if "ST" in X:
        X=X.replace("ST","",1)
    else:
        break

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
a = input()
while 1:
    if 'ST' in a:
        a = a[:a.index('ST')] + a[a.index('ST')+2:]
    else:
        break
print(len(a))

Submission status: Time Limit Exceeded

Solution code:
X = input()

i = 0
while i < len(X):
    # print(i)
    while i + 1 < len(X) and X[i:i+2] != 'ST':
        i += 1

    if i + 1 >= len(X):
        break
    X = X[:i] + X[i+2:]
    i -= 1

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
X = input()

while X.find("ST") != -1:
    X = X.replace("ST", "")

print(len(X))

Submission status: Time Limit Exceeded

Solution code:
s = raw_input()
ss = s.replace('ST', '')
while s != ss:
    s = ss
    ss = s.replace('ST', '')

print len(ss)

Submission status: Time Limit Exceeded

Solution code:
s = input()
i = int(len(s)/2)
for i in range(i):
    k = s.replace("ST","",1)
    if (s == k):
        break
    else:
        s = k
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()
i = int(len(s)/2)
for i in range(i):
    s = s.replace("ST","",1)
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
s = input()
for i in range(100000):
    s = s.replace("ST","",1)
print(len(s))

Submission status: Time Limit Exceeded

Solution code:
import sys

for x in [inp.strip() for inp in sys.stdin]:
	mem=len(x)
	while(True):
		x = x.replace("ST", "")
		if not x or mem == len(x): break
		mem = len(x)
	print len(x)