node_ids
sequencelengths
4
1.4k
edge_index
sequencelengths
1
2.22k
text
sequencelengths
4
1.4k
source
stringlengths
14
427k
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 13, 3, 4, 13, 13, 4, 13, 17, 0, 13, 2, 13, 17, 0, 13, 13, 42, 17, 42, 2, 2, 13, 13, 2, 18, 13, 13, 17, 0, 13, 17, 14, 40, 13, 13, 3, 0, 13, 17, 0, 13, 17, 0, 13, 17, 42, 2, 2, 13, 13, 2, 18, 13, 13, 17, 0, 13, 17, 14, 40, 13, 13, 3, 0, 13, 4, 13, 2, 13, 17, 13, 4, 13, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 110, 2 ], [ 113, 6 ], [ 111, 9 ], [ 12, 11 ], [ 114, 14 ], [ 111, 18 ], [ 11, 19 ], [ 122, 22 ], [ 11, 23 ], [ 114, 27 ], [ 116, 32 ], [ 123, 34 ], [ 98, 37 ], [ 114, 38 ], [ 117, 44 ], [ 102, 44 ], [ 108, 44 ], [ 129, 44 ], [ 114, 45 ], [ 111, 48 ], [ 117, 49 ], [ 102, 49 ], [ 108, 49 ], [ 129, 49 ], [ 101, 52 ], [ 102, 56 ], [ 117, 56 ], [ 108, 56 ], [ 129, 56 ], [ 114, 57 ], [ 119, 60 ], [ 128, 63 ], [ 104, 66 ], [ 105, 71 ], [ 123, 71 ], [ 126, 71 ], [ 114, 72 ], [ 111, 75 ], [ 105, 76 ], [ 123, 76 ], [ 126, 76 ], [ 125, 79 ], [ 126, 83 ], [ 105, 83 ], [ 123, 83 ], [ 114, 84 ], [ 107, 87 ], [ 126, 91 ], [ 105, 91 ], [ 123, 91 ], [ 129, 93 ], [ 102, 93 ], [ 117, 93 ], [ 108, 93 ], [ 120, 96 ], [ 99, 96 ], [ 114, 98 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ], [ 110, 111 ], [ 113, 114 ], [ 116, 117 ], [ 119, 120 ], [ 11, 122 ], [ 122, 123 ], [ 125, 126 ], [ 128, 129 ] ]
[ "x=input()\nn=len(x)\n\nfor i in range(n):\n if x[i]=='S':\n left=i\n break\nelse:\n print(n)\n exit(0)\n\nright=left+1\nans=n\n\nwhile True:\n\n while right<n and x[right]=='S':\n right+=1\n \n if right>=n:\n break\n\n ans-=2\n right+=1\n left+=1\n while left<n and x[left]=='T':\n left+=1\n \n if left>=n:\n break\n\n right=max(left+1,right)\n\n\nprint(ans)", "x=input()", "x", "input()", "input", "n=len(x)", "n", "len(x)", "len", "x", "for i in range(n):\n if x[i]=='S':\n left=i\n break\nelse:\n print(n)\n exit(0)", "i", "range(n)", "range", "n", "if x[i]=='S':\n left=i\n break", "x[i]=='S'", "x[i]", "x", "i", "'S'", "left=i", "left", "i", "break", "print(n)", "print", "n", "exit(0)", "exit", "0", "right=left+1", "right", "left+1", "left", "1", "ans=n", "ans", "n", "while True:\n\n while right<n and x[right]=='S':\n right+=1\n \n if right>=n:\n break\n\n ans-=2\n right+=1\n left+=1\n while left<n and x[left]=='T':\n left+=1\n \n if left>=n:\n break\n\n right=max(left+1,right)", "True", "while right<n and x[right]=='S':\n right+=1\n \n ", "right<n and x[right]=='S'", "right<n", "right", "n", "x[right]=='S'", "x[right]", "x", "right", "'S'", "right+=1", "right", "1", "if right>=n:\n break\n\n ", "right>=n", "right", "n", "break", "ans-=2", "ans", "2", "right+=1", "right", "1", "left+=1", "left", "1", "while left<n and x[left]=='T':\n left+=1\n \n ", "left<n and x[left]=='T'", "left<n", "left", "n", "x[left]=='T'", "x[left]", "x", "left", "'T'", "left+=1", "left", "1", "if left>=n:\n break\n\n ", "left>=n", "left", "n", "break", "right=max(left+1,right)", "right", "max(left+1,right)", "max", "left+1", "left", "1", "right", "print(ans)", "print", "ans", "ans=n", "n", "ans", "right+=1", "1", "right", "left+=1", "1", "left", "right=max(left+1,right)", "max(left+1,right)", "right", "x=input()", "input()", "x", "n=len(x)", "len(x)", "n", "right=left+1", "left+1", "right", "ans-=2", "2", "ans", "left=i", "i", "left", "left+=1", "1", "left", "right+=1", "1", "right" ]
x=input() n=len(x) for i in range(n): if x[i]=='S': left=i break else: print(n) exit(0) right=left+1 ans=n while True: while right<n and x[right]=='S': right+=1 if right>=n: break ans-=2 right+=1 left+=1 while left<n and x[left]=='T': left+=1 if left>=n: break right=max(left+1,right) print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 68, 2 ], [ 62, 6 ], [ 69, 9 ], [ 56, 11 ], [ 50, 14 ], [ 18, 17 ], [ 63, 20 ], [ 69, 24 ], [ 17, 25 ], [ 74, 28 ], [ 59, 31 ], [ 51, 35 ], [ 54, 35 ], [ 75, 35 ], [ 53, 38 ], [ 65, 41 ], [ 71, 44 ], [ 72, 48 ], [ 66, 48 ], [ 60, 48 ], [ 57, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "x = input()\nn = len(x)\n\nans = 0\ncnt = 0\nfor i in range(n):\n if x[i] == 'S':\n cnt += 1\n ans += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 1\n else:\n ans += 1\n\nprint(ans)", "x = input()", "x", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "ans = 0", "ans", "0", "cnt = 0", "cnt", "0", "for i in range(n):\n if x[i] == 'S':\n cnt += 1\n ans += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 1\n else:\n ans += 1", "i", "range(n)", "range", "n", "if x[i] == 'S':\n cnt += 1\n ans += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 1\n else:\n ans += 1", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "cnt += 1", "cnt", "1", "ans += 1", "ans", "1", "if cnt > 0:\n cnt -= 1\n ans -= 1\n else:\n ans += 1", "cnt > 0", "cnt", "0", "cnt -= 1", "cnt", "1", "ans -= 1", "ans", "1", "ans += 1", "ans", "1", "print(ans)", "print", "ans", "cnt = 0", "0", "cnt", "cnt -= 1", "1", "cnt", "ans = 0", "0", "ans", "ans += 1", "1", "ans", "n = len(x)", "len(x)", "n", "ans -= 1", "1", "ans", "x = input()", "input()", "x", "ans += 1", "1", "ans", "cnt += 1", "1", "cnt" ]
x = input() n = len(x) ans = 0 cnt = 0 for i in range(n): if x[i] == 'S': cnt += 1 ans += 1 else: if cnt > 0: cnt -= 1 ans -= 1 else: ans += 1 print(ans)
[ 7, 0, 13, 17, 28, 13, 4, 13, 0, 13, 2, 2, 13, 17, 40, 2, 13, 17, 4, 13, 2, 13, 17, 10, 2, 13, 10, 17, 13 ]
[ [ 27, 2 ], [ 6, 5 ], [ 24, 9 ], [ 5, 12 ], [ 28, 16 ], [ 25, 16 ], [ 25, 21 ], [ 28, 21 ], [ 24, 25 ], [ 27, 28 ] ]
[ "k = 0\nfor i in input():\n k += i==\"S\" or -(k>0)\nprint(k*2)", "k = 0", "k", "0", "for i in input():\n k += i==\"S\" or -(k>0)", "i", "input()", "input", "k += i==\"S\" or -(k>0)", "k", "i==\"S\" or -(k>0)", "i==\"S\"", "i", "\"S\"", "-(k>0)", "k>0", "k", "0", "print(k*2)", "print", "k*2", "k", "2", "k += i==\"S\" or -(k>0)", "i==\"S\" or -(k>0)", "k", "k = 0", "0", "k" ]
k = 0 for i in input(): k += i=="S" or -(k>0) print(k*2)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 61, 2 ], [ 76, 8 ], [ 62, 11 ], [ 67, 13 ], [ 70, 16 ], [ 20, 19 ], [ 77, 22 ], [ 62, 26 ], [ 19, 27 ], [ 58, 30 ], [ 62, 35 ], [ 19, 36 ], [ 68, 40 ], [ 65, 40 ], [ 59, 40 ], [ 73, 43 ], [ 68, 47 ], [ 65, 47 ], [ 59, 47 ], [ 64, 50 ], [ 74, 55 ], [ 71, 55 ], [ 65, 56 ], [ 59, 56 ], [ 68, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "X = list(input())\nN = len(X)\nLife = 0\nout = 0\nfor i in range(N):\n if X[i]==\"S\":\n Life += 1\n elif X[i]==\"T\":\n if Life==0:\n out += 1\n elif Life>0:\n Life += -1\nprint(out+Life)", "X = list(input())", "X", "list(input())", "list", "input()", "input", "N = len(X)", "N", "len(X)", "len", "X", "Life = 0", "Life", "0", "out = 0", "out", "0", "for i in range(N):\n if X[i]==\"S\":\n Life += 1\n elif X[i]==\"T\":\n if Life==0:\n out += 1\n elif Life>0:\n Life += -1", "i", "range(N)", "range", "N", "if X[i]==\"S\":\n Life += 1\n elif X[i]==\"T\":\n if Life==0:\n out += 1\n elif Life>0:\n Life += -1", "X[i]==\"S\"", "X[i]", "X", "i", "\"S\"", "Life += 1", "Life", "1", "elif X[i]==\"T\":\n if Life==0:\n out += 1\n elif Life>0:\n Life += -1", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "if Life==0:\n out += 1\n elif Life>0:\n Life += -1", "Life==0", "Life", "0", "out += 1", "out", "1", "elif Life>0:\n Life += -1", "Life>0", "Life", "0", "Life += -1", "Life", "-1", "print(out+Life)", "print", "out+Life", "out", "Life", "Life += 1", "1", "Life", "X = list(input())", "list(input())", "X", "Life += -1", "-1", "Life", "Life = 0", "0", "Life", "out = 0", "0", "out", "out += 1", "1", "out", "N = len(X)", "len(X)", "N" ]
X = list(input()) N = len(X) Life = 0 out = 0 for i in range(N): if X[i]=="S": Life += 1 elif X[i]=="T": if Life==0: out += 1 elif Life>0: Life += -1 print(out+Life)
[ 7, 15, 13, 12, 13, 29, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 9, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 26, 25 ], [ 69, 27 ], [ 30, 29 ], [ 33, 32 ], [ 36, 35 ], [ 25, 35 ], [ 35, 39 ], [ 43, 42 ], [ 42, 47 ], [ 32, 47 ], [ 50, 47 ], [ 51, 50 ], [ 54, 53 ], [ 57, 56 ], [ 50, 57 ], [ 42, 57 ], [ 32, 57 ], [ 56, 60 ], [ 53, 60 ], [ 29, 60 ], [ 72, 66 ] ]
[ "import sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nsys.setrecursionlimit(10 ** 9)\n\n\ndef main():\n X = input()\n answer = 0\n cnt_s = 0\n for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n else:\n answer += 1\n answer += cnt_s\n print(answer)\n\n\nif __name__ == \"__main__\":\n main()", "import sys", "sys", "def input():\n return sys.stdin.readline().strip()", "input", "return sys.stdin.readline().strip()", "sys.stdin.readline().strip()", "sys.stdin.readline().strip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "strip", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "def main():\n X = input()\n answer = 0\n cnt_s = 0\n for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n else:\n answer += 1\n answer += cnt_s\n print(answer)", "main", "X = input()", "X", "input()", "input", "answer = 0", "answer", "0", "cnt_s = 0", "cnt_s", "0", "for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n else:\n answer += 1\n ", "x", "X", "if x == \"S\":\n cnt_s += 1\n continue\n ", "x == \"S\"", "x", "\"S\"", "cnt_s += 1", "cnt_s", "1", "continue", "if cnt_s > 0:\n cnt_s -= 1\n else:\n answer += 1\n ", "cnt_s > 0", "cnt_s", "0", "cnt_s -= 1", "cnt_s", "1", "answer += 1", "answer", "1", "answer += cnt_s", "answer", "cnt_s", "print(answer)", "print", "answer", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def input():\n return sys.stdin.readline().strip()", "def input():\n return sys.stdin.readline().strip()", "input", "def main():\n X = input()\n answer = 0\n cnt_s = 0\n for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n else:\n answer += 1\n answer += cnt_s\n print(answer)", "def main():\n X = input()\n answer = 0\n cnt_s = 0\n for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n else:\n answer += 1\n answer += cnt_s\n print(answer)", "main" ]
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) def main(): X = input() answer = 0 cnt_s = 0 for x in X: if x == "S": cnt_s += 1 continue if cnt_s > 0: cnt_s -= 1 else: answer += 1 answer += cnt_s print(answer) if __name__ == "__main__": main()
[ 7, 12, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 17, 29, 2, 13, 13, 23, 13, 14, 2, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 8, 7 ], [ 11, 10 ], [ 46, 10 ], [ 10, 15 ], [ 4, 18 ], [ 39, 18 ], [ 28, 18 ], [ 22, 21 ], [ 10, 25 ], [ 29, 28 ], [ 10, 33 ], [ 4, 36 ], [ 39, 36 ], [ 28, 36 ], [ 40, 39 ], [ 39, 43 ], [ 28, 43 ], [ 4, 43 ], [ 21, 44 ], [ 7, 44 ], [ 46, 46 ], [ 66, 52 ], [ 69, 58 ], [ 73, 60 ], [ 67, 61 ], [ 70, 64 ], [ 66, 67 ], [ 69, 70 ] ]
[ "def main(X):\n cntS = 0; cntT = 0\n for x in X:\n if x == 'T' and cntS == 0:\n cntT += 1\n elif x == 'S':\n cntS += 1\n elif x == 'T' and cntS > 0:\n cntS -= 1\n else:\n pass\n return cntS + cntT\n \nif __name__ == \"__main__\":\n X = list(input())\n ans = main(X)\n print(ans)", "def main(X):\n cntS = 0; cntT = 0\n for x in X:\n if x == 'T' and cntS == 0:\n cntT += 1\n elif x == 'S':\n cntS += 1\n elif x == 'T' and cntS > 0:\n cntS -= 1\n else:\n pass\n return cntS + cntT\n ", "main", "cntS = 0", "cntS", "0", "cntT = 0", "cntT", "0", "for x in X:\n if x == 'T' and cntS == 0:\n cntT += 1\n elif x == 'S':\n cntS += 1\n elif x == 'T' and cntS > 0:\n cntS -= 1\n else:\n pass\n ", "x", "X", "if x == 'T' and cntS == 0:\n cntT += 1\n elif x == 'S':\n cntS += 1\n elif x == 'T' and cntS > 0:\n cntS -= 1\n else:\n pass\n ", "x == 'T' and cntS == 0", "x == 'T'", "x", "'T'", "cntS == 0", "cntS", "0", "cntT += 1", "cntT", "1", "elif x == 'S':\n cntS += 1\n ", "x == 'S'", "x", "'S'", "cntS += 1", "cntS", "1", "elif x == 'T' and cntS > 0:\n cntS -= 1\n ", "x == 'T' and cntS > 0", "x == 'T'", "x", "'T'", "cntS > 0", "cntS", "0", "cntS -= 1", "cntS", "1", "return cntS + cntT", "cntS + cntT", "cntS", "cntT", "X", "X", "if __name__ == \"__main__\":\n X = list(input())\n ans = main(X)\n print(ans)", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "X = list(input())", "X", "list(input())", "list", "input()", "input", "ans = main(X)", "ans", "main(X)", "main", "X", "print(ans)", "print", "ans", "X = list(input())", "list(input())", "X", "ans = main(X)", "main(X)", "ans", "def main(X):\n cntS = 0; cntT = 0\n for x in X:\n if x == 'T' and cntS == 0:\n cntT += 1\n elif x == 'S':\n cntS += 1\n elif x == 'T' and cntS > 0:\n cntS -= 1\n else:\n pass\n return cntS + cntT\n ", "def main(X):\n cntS = 0; cntT = 0\n for x in X:\n if x == 'T' and cntS == 0:\n cntT += 1\n elif x == 'S':\n cntS += 1\n elif x == 'T' and cntS > 0:\n cntS -= 1\n else:\n pass\n return cntS + cntT\n ", "main" ]
def main(X): cntS = 0; cntT = 0 for x in X: if x == 'T' and cntS == 0: cntT += 1 elif x == 'S': cntS += 1 elif x == 'T' and cntS > 0: cntS -= 1 else: pass return cntS + cntT if __name__ == "__main__": X = list(input()) ans = main(X) print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 54, 2 ], [ 57, 6 ], [ 55, 9 ], [ 72, 11 ], [ 69, 14 ], [ 18, 17 ], [ 58, 20 ], [ 55, 24 ], [ 17, 25 ], [ 60, 28 ], [ 55, 34 ], [ 17, 35 ], [ 73, 38 ], [ 67, 38 ], [ 61, 38 ], [ 63, 41 ], [ 66, 44 ], [ 58, 49 ], [ 64, 51 ], [ 70, 51 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "X = input()\n\nn = len(X)\n\nS_cnt = 0\ncnt = 0\n\nfor i in range(n):\n if X[i]=='S':\n S_cnt += 1\n elif (X[i]=='T') and(S_cnt>0):\n cnt += 1\n S_cnt -= 1\nprint(n-cnt*2)", "X = input()", "X", "input()", "input", "n = len(X)", "n", "len(X)", "len", "X", "S_cnt = 0", "S_cnt", "0", "cnt = 0", "cnt", "0", "for i in range(n):\n if X[i]=='S':\n S_cnt += 1\n elif (X[i]=='T') and(S_cnt>0):\n cnt += 1\n S_cnt -= 1", "i", "range(n)", "range", "n", "if X[i]=='S':\n S_cnt += 1\n elif (X[i]=='T') and(S_cnt>0):\n cnt += 1\n S_cnt -= 1", "X[i]=='S'", "X[i]", "X", "i", "'S'", "S_cnt += 1", "S_cnt", "1", "elif (X[i]=='T') and(S_cnt>0):\n cnt += 1\n S_cnt -= 1", "(X[i]=='T') and(S_cnt>0)", "X[i]=='T'", "X[i]", "X", "i", "'T'", "S_cnt>0", "S_cnt", "0", "cnt += 1", "cnt", "1", "S_cnt -= 1", "S_cnt", "1", "print(n-cnt*2)", "print", "n-cnt*2", "n", "cnt*2", "cnt", "2", "X = input()", "input()", "X", "n = len(X)", "len(X)", "n", "S_cnt += 1", "1", "S_cnt", "cnt += 1", "1", "cnt", "S_cnt -= 1", "1", "S_cnt", "cnt = 0", "0", "cnt", "S_cnt = 0", "0", "S_cnt" ]
X = input() n = len(X) S_cnt = 0 cnt = 0 for i in range(n): if X[i]=='S': S_cnt += 1 elif (X[i]=='T') and(S_cnt>0): cnt += 1 S_cnt -= 1 print(n-cnt*2)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 2, 2, 13, 17, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 2, 13, 2, 17, 13, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 69, 2 ], [ 63, 8 ], [ 70, 11 ], [ 75, 13 ], [ 66, 16 ], [ 20, 19 ], [ 64, 22 ], [ 70, 26 ], [ 64, 29 ], [ 19, 31 ], [ 78, 34 ], [ 76, 38 ], [ 61, 38 ], [ 79, 38 ], [ 60, 41 ], [ 57, 44 ], [ 72, 47 ], [ 64, 49 ], [ 58, 52 ], [ 67, 52 ], [ 73, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "X = str(input())\n\nn = len(X)\ntmp = 0\ncnt = 0\nfor i in range(n):\n if X[n-1-i] == 'T':\n tmp += 1\n else:\n if tmp > 0:\n tmp -= 1\n cnt += 1\n\nans = n - 2*cnt\nprint(ans)", "X = str(input())", "X", "str(input())", "str", "input()", "input", "n = len(X)", "n", "len(X)", "len", "X", "tmp = 0", "tmp", "0", "cnt = 0", "cnt", "0", "for i in range(n):\n if X[n-1-i] == 'T':\n tmp += 1\n else:\n if tmp > 0:\n tmp -= 1\n cnt += 1", "i", "range(n)", "range", "n", "if X[n-1-i] == 'T':\n tmp += 1\n else:\n if tmp > 0:\n tmp -= 1\n cnt += 1", "X[n-1-i] == 'T'", "X[n-1-i]", "X", "n-1-i", "n-1", "n", "1", "i", "'T'", "tmp += 1", "tmp", "1", "if tmp > 0:\n tmp -= 1\n cnt += 1", "tmp > 0", "tmp", "0", "tmp -= 1", "tmp", "1", "cnt += 1", "cnt", "1", "ans = n - 2*cnt", "ans", "n - 2*cnt", "n", "2*cnt", "2", "cnt", "print(ans)", "print", "ans", "cnt += 1", "1", "cnt", "tmp -= 1", "1", "tmp", "n = len(X)", "len(X)", "n", "cnt = 0", "0", "cnt", "X = str(input())", "str(input())", "X", "ans = n - 2*cnt", "n - 2*cnt", "ans", "tmp = 0", "0", "tmp", "tmp += 1", "1", "tmp" ]
X = str(input()) n = len(X) tmp = 0 cnt = 0 for i in range(n): if X[n-1-i] == 'T': tmp += 1 else: if tmp > 0: tmp -= 1 cnt += 1 ans = n - 2*cnt print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 2, 4, 13, 13, 17, 0, 13, 2, 4, 13, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13, 10, 17, 13 ]
[ [ 69, 2 ], [ 72, 6 ], [ 70, 10 ], [ 87, 13 ], [ 70, 17 ], [ 81, 20 ], [ 90, 23 ], [ 27, 26 ], [ 70, 26 ], [ 26, 30 ], [ 75, 33 ], [ 63, 36 ], [ 66, 39 ], [ 84, 42 ], [ 67, 46 ], [ 76, 46 ], [ 82, 46 ], [ 61, 46 ], [ 78, 49 ], [ 60, 52 ], [ 79, 57 ], [ 91, 57 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ] ]
[ "X = input()\nTnum = len(X) // 2\nSnum = len(X) // 2\nnum = 0\nans = 0\nfor i in X:\n if i == 'T':\n num -= 1\n Tnum -= 1\n else:\n num += 1\n Snum -= 1\n\n if num < 0:\n ans += 1\n num = 0\nprint(ans*2)", "X = input()", "X", "input()", "input", "Tnum = len(X) // 2", "Tnum", "len(X) // 2", "len(X)", "len", "X", "2", "Snum = len(X) // 2", "Snum", "len(X) // 2", "len(X)", "len", "X", "2", "num = 0", "num", "0", "ans = 0", "ans", "0", "for i in X:\n if i == 'T':\n num -= 1\n Tnum -= 1\n else:\n num += 1\n Snum -= 1\n\n if num < 0:\n ans += 1\n num = 0", "i", "X", "if i == 'T':\n num -= 1\n Tnum -= 1\n else:\n num += 1\n Snum -= 1\n\n ", "i == 'T'", "i", "'T'", "num -= 1", "num", "1", "Tnum -= 1", "Tnum", "1", "num += 1", "num", "1", "Snum -= 1", "Snum", "1", "if num < 0:\n ans += 1\n num = 0", "num < 0", "num", "0", "ans += 1", "ans", "1", "num = 0", "num", "0", "print(ans*2)", "print", "ans*2", "ans", "2", "num = 0", "0", "num", "Tnum -= 1", "1", "Tnum", "num += 1", "1", "num", "X = input()", "input()", "X", "Tnum = len(X) // 2", "len(X) // 2", "Tnum", "num -= 1", "1", "num", "ans += 1", "1", "ans", "num = 0", "0", "num", "Snum -= 1", "1", "Snum", "Snum = len(X) // 2", "len(X) // 2", "Snum", "ans = 0", "0", "ans" ]
X = input() Tnum = len(X) // 2 Snum = len(X) // 2 num = 0 ans = 0 for i in X: if i == 'T': num -= 1 Tnum -= 1 else: num += 1 Snum -= 1 if num < 0: ans += 1 num = 0 print(ans*2)
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 15, 12, 13, 0, 13, 4, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 18, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 14, 2, 2, 13, 18, 13, 13, 17, 14, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 17, 4, 18, 13, 13, 13, 0, 13, 18, 13, 13, 4, 13, 2, 4, 13, 13, 13, 14, 2, 13, 17, 4, 13, 10, 18, 13, 10, 12, 13 ]
[ [ 92, 4 ], [ 15, 14 ], [ 93, 20 ], [ 24, 23 ], [ 28, 27 ], [ 31, 30 ], [ 14, 32 ], [ 36, 35 ], [ 14, 41 ], [ 30, 45 ], [ 74, 45 ], [ 63, 45 ], [ 57, 45 ], [ 14, 47 ], [ 35, 48 ], [ 23, 54 ], [ 58, 57 ], [ 23, 60 ], [ 64, 63 ], [ 67, 66 ], [ 23, 70 ], [ 30, 72 ], [ 74, 72 ], [ 63, 72 ], [ 57, 72 ], [ 75, 74 ], [ 14, 76 ], [ 35, 77 ], [ 14, 83 ], [ 66, 84 ], [ 27, 84 ], [ 96, 90 ], [ 92, 93 ] ]
[ "import sys\ninput = sys.stdin.readline\nfrom collections import deque\ndef main():\n X = list(input().rstrip())\n past = deque()\n cnt = 0\n last = X[0]\n for i in range(1,len(X)):\n if last + X[i] == 'ST':\n if len(past) > 0:\n last = past.pop()\n else:\n last = ''\n cnt += 2\n else:\n past.append(last)\n last = X[i]\n print(len(X) - cnt)\n \nif __name__ == '__main__':\n main()", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "from collections import deque", "def main():\n X = list(input().rstrip())\n past = deque()\n cnt = 0\n last = X[0]\n for i in range(1,len(X)):\n if last + X[i] == 'ST':\n if len(past) > 0:\n last = past.pop()\n else:\n last = ''\n cnt += 2\n else:\n past.append(last)\n last = X[i]\n print(len(X) - cnt)\n ", "main", "X = list(input().rstrip())", "X", "list(input().rstrip())", "list", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "past = deque()", "past", "deque()", "deque", "cnt = 0", "cnt", "0", "last = X[0]", "last", "X[0]", "X", "0", "for i in range(1,len(X)):\n if last + X[i] == 'ST':\n if len(past) > 0:\n last = past.pop()\n else:\n last = ''\n cnt += 2\n else:\n past.append(last)\n last = X[i]\n ", "i", "range(1,len(X))", "range", "1", "len(X)", "len", "X", "if last + X[i] == 'ST':\n if len(past) > 0:\n last = past.pop()\n else:\n last = ''\n cnt += 2\n else:\n past.append(last)\n last = X[i]\n ", "last + X[i] == 'ST'", "last + X[i]", "last", "X[i]", "X", "i", "'ST'", "if len(past) > 0:\n last = past.pop()\n else:\n last = ''\n ", "len(past) > 0", "len(past)", "len", "past", "0", "last = past.pop()", "last", "past.pop()", "past.pop", "past", "pop", "last = ''", "last", "''", "cnt += 2", "cnt", "2", "past.append(last)", "past.append", "past", "append", "last", "last = X[i]", "last", "X[i]", "X", "i", "print(len(X) - cnt)", "print", "len(X) - cnt", "len(X)", "len", "X", "cnt", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input", "def main():\n X = list(input().rstrip())\n past = deque()\n cnt = 0\n last = X[0]\n for i in range(1,len(X)):\n if last + X[i] == 'ST':\n if len(past) > 0:\n last = past.pop()\n else:\n last = ''\n cnt += 2\n else:\n past.append(last)\n last = X[i]\n print(len(X) - cnt)\n ", "def main():\n X = list(input().rstrip())\n past = deque()\n cnt = 0\n last = X[0]\n for i in range(1,len(X)):\n if last + X[i] == 'ST':\n if len(past) > 0:\n last = past.pop()\n else:\n last = ''\n cnt += 2\n else:\n past.append(last)\n last = X[i]\n print(len(X) - cnt)\n ", "main" ]
import sys input = sys.stdin.readline from collections import deque def main(): X = list(input().rstrip()) past = deque() cnt = 0 last = X[0] for i in range(1,len(X)): if last + X[i] == 'ST': if len(past) > 0: last = past.pop() else: last = '' cnt += 2 else: past.append(last) last = X[i] print(len(X) - cnt) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 0, 13, 39, 0, 13, 39, 28, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 13, 2, 4, 13, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13, 10, 39, 13 ]
[ [ 51, 2 ], [ 57, 6 ], [ 54, 9 ], [ 52, 16 ], [ 58, 23 ], [ 58, 30 ], [ 58, 34 ], [ 55, 38 ], [ 58, 46 ], [ 55, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "x = input()\ns_q = []\narc = []\nfor i, v in enumerate(x):\n if v == 'S':\n s_q.append(v)\n else:\n if len(s_q) > 0:\n s_q.pop()\n else:\n arc.append(v)\nprint(len(s_q)+len(arc))\n", "x = input()", "x", "input()", "input", "s_q = []", "s_q", "[]", "arc = []", "arc", "[]", "for i, v in enumerate(x):\n if v == 'S':\n s_q.append(v)\n else:\n if len(s_q) > 0:\n s_q.pop()\n else:\n arc.append(v)", "i", "v", "enumerate(x)", "enumerate", "x", "if v == 'S':\n s_q.append(v)\n else:\n if len(s_q) > 0:\n s_q.pop()\n else:\n arc.append(v)", "v == 'S'", "v", "'S'", "s_q.append(v)", "s_q.append", "s_q", "append", "v", "if len(s_q) > 0:\n s_q.pop()\n else:\n arc.append(v)", "len(s_q) > 0", "len(s_q)", "len", "s_q", "0", "s_q.pop()", "s_q.pop", "s_q", "pop", "arc.append(v)", "arc.append", "arc", "append", "v", "print(len(s_q)+len(arc))", "print", "len(s_q)+len(arc)", "len(s_q)", "len", "s_q", "len(arc)", "len", "arc", "x = input()", "input()", "x", "arc = []", "[]", "arc", "s_q = []", "[]", "s_q" ]
x = input() s_q = [] arc = [] for i, v in enumerate(x): if v == 'S': s_q.append(v) else: if len(s_q) > 0: s_q.pop() else: arc.append(v) print(len(s_q)+len(arc))
[ 7, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 41, 28, 13, 4, 13, 13, 4, 4, 18, 4, 13, 13, 12, 13, 23, 13, 41, 28, 13, 4, 13, 13, 4, 13, 12, 13, 23, 13, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 12, 13, 23, 13, 41, 28, 13, 4, 13, 13, 4, 13, 12, 13, 23, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 13, 12, 13, 23, 13, 12, 13, 23, 13, 23, 13, 17, 23, 13, 17, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13 ]
[ [ 8, 7 ], [ 17, 17 ], [ 21, 20 ], [ 33, 33 ], [ 37, 36 ], [ 191, 38 ], [ 45, 45 ], [ 51, 50 ], [ 50, 59 ], [ 65, 64 ], [ 76, 76 ], [ 80, 79 ], [ 88, 88 ], [ 92, 91 ], [ 104, 104 ], [ 108, 108 ], [ 111, 110 ], [ 114, 113 ], [ 199, 116 ], [ 197, 118 ], [ 157, 120 ], [ 172, 123 ], [ 127, 126 ], [ 200, 126 ], [ 126, 130 ], [ 173, 134 ], [ 188, 134 ], [ 167, 134 ], [ 178, 137 ], [ 166, 140 ], [ 187, 143 ], [ 179, 148 ], [ 158, 148 ], [ 157, 158 ], [ 166, 167 ], [ 172, 173 ], [ 178, 179 ], [ 187, 188 ], [ 199, 200 ] ]
[ "\ndef s0():return input()\ndef s1():return input().split()\ndef s2(n):return [input() for x in range(n)]\ndef s3(n):return [input().split() for _ in range(n)]\ndef s4(n):return [[x for x in s] for s in s2(n)]\ndef n0():return int(input())\ndef n1():return [int(x) for x in input().split()]\ndef n2(n):return [int(input()) for _ in range(n)]\ndef n3(n):return [[int(x) for x in input().split()] for _ in range(n)]\ndef t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]\ndef p0(b,yes=\"Yes\",no=\"No\"): print(yes if b else no)\n# from sys import setrecursionlimit\n# setrecursionlimit(1000000)\n# from collections import Counter,deque,defaultdict\n# import itertools\n# import math\n# import networkx as nx\n# from bisect import bisect_left,bisect_right\n# from heapq import heapify,heappush,heappop\nx=s0()\n\nans=0\nc=0\nfor s in x:\n if s==\"T\":\n if c==0:\n ans+=1\n else:\n c-=1\n else:\n c+=1\nprint(ans*2)", "def s0():return input()", "s0", "def s1():return input().split()", "s1", "input() for x in range(n)", "for x in range(n)", "x", "range(n)", "range", "n", "for x in range(n)", "input()", "input", "def s2(n):return [input() for x in range(n)]", "s2", "n", "n", "input().split() for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "input().split()", "().split", "()", "input", "split", "def s3(n):return [input().split() for _ in range(n)]", "s3", "n", "n", "[x for x in s] for s in s2(n)", "for s in s2(n)", "s", "s2(n)", "s2", "n", "for s in s2(n)", "[x for x in s]", "def s4(n):return [[x for x in s] for s in s2(n)]", "s4", "n", "n", "def n0():return int(input())", "n0", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "def n1():return [int(x) for x in input().split()]", "n1", "int(input()) for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "int(input())", "int", "input()", "input", "def n2(n):return [int(input()) for _ in range(n)]", "n2", "n", "n", "[int(x) for x in input().split()] for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "[int(x) for x in input().split()]", "def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]", "n3", "n", "n", "tuple(int(x) for x in input().split()) for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "tuple(int(x) for x in input().split())", "tuple", "int(x)", "int", "x", "def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]", "t3", "n", "n", "def p0(b,yes=\"Yes\",no=\"No\"): print(yes if b else no)\n# from sys import setrecursionlimit\n# setrecursionlimit(1000000)\n# from collections import Counter,deque,defaultdict\n# import itertools\n# import math\n# import networkx as nx\n# from bisect import bisect_left,bisect_right\n# from heapq import heapify,heappush,heappop", "p0", "b", "b", "yes=\"Yes\"", "yes", "\"Yes\"", "no=\"No\"", "no", "\"No\"", "x=s0()", "x", "s0()", "s0", "ans=0", "ans", "0", "c=0", "c", "0", "for s in x:\n if s==\"T\":\n if c==0:\n ans+=1\n else:\n c-=1\n else:\n c+=1", "s", "x", "if s==\"T\":\n if c==0:\n ans+=1\n else:\n c-=1\n else:\n c+=1", "s==\"T\"", "s", "\"T\"", "if c==0:\n ans+=1\n else:\n c-=1\n ", "c==0", "c", "0", "ans+=1", "ans", "1", "c-=1", "c", "1", "c+=1", "c", "1", "print(ans*2)", "print", "ans*2", "ans", "2", "def s3(n):return [input().split() for _ in range(n)]", "def s3(n):return [input().split() for _ in range(n)]", "s3", "def n0():return int(input())", "def n0():return int(input())", "n0", "ans=0", "0", "ans", "def s4(n):return [[x for x in s] for s in s2(n)]", "def s4(n):return [[x for x in s] for s in s2(n)]", "s4", "def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]", "def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]", "t3", "c-=1", "1", "c", "def p0(b,yes=\"Yes\",no=\"No\"): print(yes if b else no)\n# from sys import setrecursionlimit\n# setrecursionlimit(1000000)\n# from collections import Counter,deque,defaultdict\n# import itertools\n# import math\n# import networkx as nx\n# from bisect import bisect_left,bisect_right\n# from heapq import heapify,heappush,heappop", "def p0(b,yes=\"Yes\",no=\"No\"): print(yes if b else no)\n# from sys import setrecursionlimit\n# setrecursionlimit(1000000)\n# from collections import Counter,deque,defaultdict\n# import itertools\n# import math\n# import networkx as nx\n# from bisect import bisect_left,bisect_right\n# from heapq import heapify,heappush,heappop", "p0", "c=0", "0", "c", "def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]", "def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]", "n3", "ans+=1", "1", "ans", "def n2(n):return [int(input()) for _ in range(n)]", "def n2(n):return [int(input()) for _ in range(n)]", "n2", "def n1():return [int(x) for x in input().split()]", "def n1():return [int(x) for x in input().split()]", "n1", "c+=1", "1", "c", "def s2(n):return [input() for x in range(n)]", "def s2(n):return [input() for x in range(n)]", "s2", "def s1():return input().split()", "def s1():return input().split()", "s1", "def s0():return input()", "def s0():return input()", "s0", "x=s0()", "s0()", "x" ]
def s0():return input() def s1():return input().split() def s2(n):return [input() for x in range(n)] def s3(n):return [input().split() for _ in range(n)] def s4(n):return [[x for x in s] for s in s2(n)] def n0():return int(input()) def n1():return [int(x) for x in input().split()] def n2(n):return [int(input()) for _ in range(n)] def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)] def p0(b,yes="Yes",no="No"): print(yes if b else no) # from sys import setrecursionlimit # setrecursionlimit(1000000) # from collections import Counter,deque,defaultdict # import itertools # import math # import networkx as nx # from bisect import bisect_left,bisect_right # from heapq import heapify,heappush,heappop x=s0() ans=0 c=0 for s in x: if s=="T": if c==0: ans+=1 else: c-=1 else: c+=1 print(ans*2)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 58, 2 ], [ 55, 8 ], [ 64, 11 ], [ 15, 14 ], [ 59, 19 ], [ 59, 23 ], [ 14, 24 ], [ 52, 27 ], [ 65, 31 ], [ 50, 31 ], [ 53, 31 ], [ 61, 34 ], [ 49, 37 ], [ 59, 44 ], [ 62, 46 ], [ 56, 46 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "S = str(input())\nans = 0\ns_ctr = 0\n# s の後の t をひたすら省く\nfor i in range(len(S)):\n if S[i] == \"S\":\n s_ctr += 1\n else:\n if s_ctr > 0:\n ans += 1\n s_ctr -= 1\nprint(len(S) - ans * 2)", "S = str(input())", "S", "str(input())", "str", "input()", "input", "ans = 0", "ans", "0", "s_ctr = 0", "s_ctr", "0", "for i in range(len(S)):\n if S[i] == \"S\":\n s_ctr += 1\n else:\n if s_ctr > 0:\n ans += 1\n s_ctr -= 1", "i", "range(len(S))", "range", "len(S)", "len", "S", "if S[i] == \"S\":\n s_ctr += 1\n else:\n if s_ctr > 0:\n ans += 1\n s_ctr -= 1", "S[i] == \"S\"", "S[i]", "S", "i", "\"S\"", "s_ctr += 1", "s_ctr", "1", "if s_ctr > 0:\n ans += 1\n s_ctr -= 1", "s_ctr > 0", "s_ctr", "0", "ans += 1", "ans", "1", "s_ctr -= 1", "s_ctr", "1", "print(len(S) - ans * 2)", "print", "len(S) - ans * 2", "len(S)", "len", "S", "ans * 2", "ans", "2", "s_ctr -= 1", "1", "s_ctr", "s_ctr += 1", "1", "s_ctr", "ans = 0", "0", "ans", "S = str(input())", "str(input())", "S", "ans += 1", "1", "ans", "s_ctr = 0", "0", "s_ctr" ]
S = str(input()) ans = 0 s_ctr = 0 # s の後の t をひたすら省く for i in range(len(S)): if S[i] == "S": s_ctr += 1 else: if s_ctr > 0: ans += 1 s_ctr -= 1 print(len(S) - ans * 2)
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 2, 2, 4, 13, 13, 17, 2, 18, 13, 17, 17, 2, 13, 17, 4, 18, 13, 13, 9, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 43, 2 ], [ 46, 6 ], [ 10, 9 ], [ 44, 9 ], [ 47, 17 ], [ 47, 21 ], [ 9, 25 ], [ 47, 29 ], [ 47, 34 ], [ 9, 36 ], [ 47, 41 ], [ 43, 44 ], [ 46, 47 ] ]
[ "x=input()\nl=[]\nfor i in x:\n if len(l)>0 and l[-1]=='S' and i=='T':\n l.pop()\n continue\n l.append(i)\nprint(len(l))", "x=input()", "x", "input()", "input", "l=[]", "l", "[]", "for i in x:\n if len(l)>0 and l[-1]=='S' and i=='T':\n l.pop()\n continue\n l.append(i)", "i", "x", "if len(l)>0 and l[-1]=='S' and i=='T':\n l.pop()\n continue\n ", "len(l)>0 and l[-1]=='S' and i=='T'", "len(l)>0 and l[-1]=='S'", "len(l)>0", "len(l)", "len", "l", "0", "l[-1]=='S'", "l[-1]", "l", "-1", "'S'", "i=='T'", "i", "'T'", "l.pop()", "l.pop", "l", "pop", "continue", "l.append(i)", "l.append", "l", "append", "i", "print(len(l))", "print", "len(l)", "len", "l", "x=input()", "input()", "x", "l=[]", "[]", "l" ]
x=input() l=[] for i in x: if len(l)>0 and l[-1]=='S' and i=='T': l.pop() continue l.append(i) print(len(l))
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 2, 13, 17, 14, 2, 13, 13, 0, 13, 13, 0, 13, 2, 13, 17, 4, 13, 2, 13, 17, 10, 2, 13, 10, 2, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 56, 2 ], [ 62, 6 ], [ 59, 9 ], [ 13, 12 ], [ 57, 17 ], [ 57, 21 ], [ 12, 22 ], [ 47, 25 ], [ 63, 27 ], [ 51, 27 ], [ 48, 27 ], [ 48, 31 ], [ 63, 31 ], [ 51, 31 ], [ 60, 32 ], [ 54, 32 ], [ 53, 34 ], [ 48, 35 ], [ 63, 35 ], [ 51, 35 ], [ 50, 37 ], [ 63, 39 ], [ 51, 39 ], [ 48, 39 ], [ 54, 44 ], [ 60, 44 ], [ 47, 48 ], [ 50, 51 ], [ 48, 53 ], [ 63, 53 ], [ 51, 53 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "x=input()\na=0\nans=0\nfor i in range(len(x)):\n if x[i]==\"T\":\n a=a+1\n if a>ans:\n ans=a\n else:\n a=a-1\nprint(ans*2)", "x=input()", "x", "input()", "input", "a=0", "a", "0", "ans=0", "ans", "0", "for i in range(len(x)):\n if x[i]==\"T\":\n a=a+1\n if a>ans:\n ans=a\n else:\n a=a-1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i]==\"T\":\n a=a+1\n if a>ans:\n ans=a\n else:\n a=a-1", "x[i]==\"T\"", "x[i]", "x", "i", "\"T\"", "a=a+1", "a", "a+1", "a", "1", "if a>ans:\n ans=a\n ", "a>ans", "a", "ans", "ans=a", "ans", "a", "a=a-1", "a", "a-1", "a", "1", "print(ans*2)", "print", "ans*2", "ans", "2", "a=a+1", "a+1", "a", "a=a-1", "a-1", "a", "ans=a", "a", "ans", "x=input()", "input()", "x", "ans=0", "0", "ans", "a=0", "0", "a" ]
x=input() a=0 ans=0 for i in range(len(x)): if x[i]=="T": a=a+1 if a>ans: ans=a else: a=a-1 print(ans*2)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 14, 40, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 44, 2 ], [ 41, 6 ], [ 56, 9 ], [ 13, 12 ], [ 45, 12 ], [ 12, 16 ], [ 59, 19 ], [ 47, 22 ], [ 42, 26 ], [ 51, 26 ], [ 60, 26 ], [ 50, 29 ], [ 62, 32 ], [ 53, 35 ], [ 54, 39 ], [ 63, 39 ], [ 48, 39 ], [ 57, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "X = input()\n\ns = 0\nans = 0\nfor Xi in X:\n if Xi == 'S':\n s += 1\n ans += 1\n else:\n if s >= 1:\n s -= 1\n ans -= 1\n else:\n ans += 1\nprint(ans)", "X = input()", "X", "input()", "input", "s = 0", "s", "0", "ans = 0", "ans", "0", "for Xi in X:\n if Xi == 'S':\n s += 1\n ans += 1\n else:\n if s >= 1:\n s -= 1\n ans -= 1\n else:\n ans += 1", "Xi", "X", "if Xi == 'S':\n s += 1\n ans += 1\n else:\n if s >= 1:\n s -= 1\n ans -= 1\n else:\n ans += 1", "Xi == 'S'", "Xi", "'S'", "s += 1", "s", "1", "ans += 1", "ans", "1", "if s >= 1:\n s -= 1\n ans -= 1\n else:\n ans += 1", "s >= 1", "s", "1", "s -= 1", "s", "1", "ans -= 1", "ans", "1", "ans += 1", "ans", "1", "print(ans)", "print", "ans", "s = 0", "0", "s", "X = input()", "input()", "X", "ans += 1", "1", "ans", "s -= 1", "1", "s", "ans += 1", "1", "ans", "ans = 0", "0", "ans", "s += 1", "1", "s", "ans -= 1", "1", "ans" ]
X = input() s = 0 ans = 0 for Xi in X: if Xi == 'S': s += 1 ans += 1 else: if s >= 1: s -= 1 ans -= 1 else: ans += 1 print(ans)
[ 7, 15, 15, 15, 15, 15, 15, 13, 15, 13, 4, 18, 13, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 10, 17, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 98, 16 ], [ 104, 43 ], [ 110, 47 ], [ 107, 50 ], [ 54, 53 ], [ 105, 58 ], [ 105, 62 ], [ 53, 63 ], [ 101, 66 ], [ 111, 70 ], [ 93, 70 ], [ 102, 70 ], [ 92, 73 ], [ 86, 76 ], [ 105, 83 ], [ 87, 84 ], [ 108, 84 ], [ 86, 87 ], [ 92, 93 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ], [ 110, 111 ] ]
[ "from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations # (string,3) 3回\nfrom collections import deque\nfrom collections import defaultdict\nimport bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# pythonで無理なときは、pypyでやると正解するかも!!\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\nX = input()\ncnt = 0\nans = 0\nfor i in range(len(X)):\n if X[i] == 'S':\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans += 2\nprint(len(X) - ans)", "from statistics import median", "from fractions import gcd", "from itertools import combinations", "from collections import deque", "from collections import defaultdict", "import bisect", "bisect", "import sys", "sys", "sys.setrecursionlimit(10000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10000000", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "def readInts():\n return list(map(int,input().split()))", "readInts", "return list(map(int,input().split()))", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def I():\n return int(input())", "I", "return int(input())", "int(input())", "int", "input()", "input", "X = input()", "X", "input()", "input", "cnt = 0", "cnt", "0", "ans = 0", "ans", "0", "for i in range(len(X)):\n if X[i] == 'S':\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans += 2", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == 'S':\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans += 2", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "cnt += 1", "cnt", "1", "if cnt > 0:\n cnt -= 1\n ans += 2", "cnt > 0", "cnt", "0", "cnt -= 1", "cnt", "1", "ans += 2", "ans", "2", "print(len(X) - ans)", "print", "len(X) - ans", "len(X)", "len", "X", "ans", "ans += 2", "2", "ans", "def I():\n return int(input())", "def I():\n return int(input())", "I", "cnt -= 1", "1", "cnt", "def readInts():\n return list(map(int,input().split()))", "def readInts():\n return list(map(int,input().split()))", "readInts", "mod = 10**9 + 7", "10**9 + 7", "mod", "cnt += 1", "1", "cnt", "X = input()", "input()", "X", "ans = 0", "0", "ans", "cnt = 0", "0", "cnt" ]
from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations # (string,3) 3回 from collections import deque from collections import defaultdict import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonで無理なときは、pypyでやると正解するかも!! # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 def readInts(): return list(map(int,input().split())) def I(): return int(input()) X = input() cnt = 0 ans = 0 for i in range(len(X)): if X[i] == 'S': cnt += 1 else: if cnt > 0: cnt -= 1 ans += 2 print(len(X) - ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 4, 13, 17, 13, 14, 2, 18, 13, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 55, 2 ], [ 64, 8 ], [ 52, 11 ], [ 61, 14 ], [ 56, 17 ], [ 20, 19 ], [ 62, 23 ], [ 56, 27 ], [ 19, 28 ], [ 53, 32 ], [ 59, 32 ], [ 68, 32 ], [ 49, 35 ], [ 67, 38 ], [ 58, 41 ], [ 50, 47 ], [ 65, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "X = str(input())\n\nTn = 0\nSn = 0\nNagasa = len(X)\n\nfor i in range (0, Nagasa):\n\tif X[i] == 'T':\n\t\tif Sn == 0:\n\t\t\tTn+=1\n\t\telse:\n\t\t\tSn-=1\n\telse:\n\t\tSn+=1\n\nprint(2*Tn)\t\t", "X = str(input())", "X", "str(input())", "str", "input()", "input", "Tn = 0", "Tn", "0", "Sn = 0", "Sn", "0", "Nagasa = len(X)", "Nagasa", "len(X)", "len", "X", "for i in range (0, Nagasa):\n\tif X[i] == 'T':\n\t\tif Sn == 0:\n\t\t\tTn+=1\n\t\telse:\n\t\t\tSn-=1\n\telse:\n\t\tSn+=1", "i", "range (0, Nagasa)", "range", "0", "Nagasa", "if X[i] == 'T':\n\t\tif Sn == 0:\n\t\t\tTn+=1\n\t\telse:\n\t\t\tSn-=1\n\telse:\n\t\tSn+=1", "X[i] == 'T'", "X[i]", "X", "i", "'T'", "if Sn == 0:\n\t\t\tTn+=1\n\t\telse:\n\t\t\tSn-=1\n\t", "Sn == 0", "Sn", "0", "Tn+=1", "Tn", "1", "Sn-=1", "Sn", "1", "Sn+=1", "Sn", "1", "print(2*Tn)", "print", "2*Tn", "2", "Tn", "Tn+=1", "1", "Tn", "Sn = 0", "0", "Sn", "X = str(input())", "str(input())", "X", "Sn+=1", "1", "Sn", "Nagasa = len(X)", "len(X)", "Nagasa", "Tn = 0", "0", "Tn", "Sn-=1", "1", "Sn" ]
X = str(input()) Tn = 0 Sn = 0 Nagasa = len(X) for i in range (0, Nagasa): if X[i] == 'T': if Sn == 0: Tn+=1 else: Sn-=1 else: Sn+=1 print(2*Tn)
[ 7, 15, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 15, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 17, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 24, 23 ], [ 134, 29 ], [ 33, 33 ], [ 109, 42 ], [ 124, 47 ], [ 118, 55 ], [ 137, 57 ], [ 115, 59 ], [ 127, 62 ], [ 66, 65 ], [ 119, 70 ], [ 119, 74 ], [ 65, 75 ], [ 100, 78 ], [ 128, 83 ], [ 131, 83 ], [ 101, 83 ], [ 103, 85 ], [ 130, 88 ], [ 119, 95 ], [ 104, 98 ], [ 116, 98 ], [ 100, 101 ], [ 103, 104 ], [ 109, 110 ], [ 115, 116 ], [ 118, 119 ], [ 124, 125 ], [ 127, 128 ], [ 130, 131 ] ]
[ "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7 \n#mod = 998244353\nfrom decimal import *\n#import numpy as np\n#decimal.getcontext().prec = 10\n\nX = input()\n\ncnt = 0\ns = 0\n\nfor i in range(len(X)):\n\tif X[i] == \"S\":\n\t\ts += 1\n\telse:\n\t\tif 0 < s:\n\t\t\tcnt += 1\n\t\t\ts -= 1\n\nprint(len(X)-2*cnt)", "import sys, re", "sys", "re", "from collections import deque, defaultdict, Counter", "from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd", "from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby", "from operator import itemgetter, mul", "from copy import deepcopy", "from string import ascii_lowercase, ascii_uppercase, digits", "from bisect import bisect, bisect_left, insort, insort_left", "from heapq import heappush, heappop", "from functools import reduce", "def input(): return sys.stdin.readline().strip()", "input", "def INT(): return int(input())", "INT", "def MAP(): return map(int, input().split())", "MAP", "def LIST(): return list(map(int, input().split()))", "LIST", "MAP() for _ in range(n)", "for _ in range(n)", "_", "range(n)", "range", "n", "for _ in range(n)", "MAP()", "MAP", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "ZIP", "n", "n", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "from decimal import *", "X = input()", "X", "input()", "input", "cnt = 0", "cnt", "0", "s = 0", "s", "0", "for i in range(len(X)):\n\tif X[i] == \"S\":\n\t\ts += 1\n\telse:\n\t\tif 0 < s:\n\t\t\tcnt += 1\n\t\t\ts -= 1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == \"S\":\n\t\ts += 1\n\telse:\n\t\tif 0 < s:\n\t\t\tcnt += 1\n\t\t\ts -= 1", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "s += 1", "s", "1", "if 0 < s:\n\t\t\tcnt += 1\n\t\t\ts -= 1", "0 < s", "0", "s", "cnt += 1", "cnt", "1", "s -= 1", "s", "1", "print(len(X)-2*cnt)", "print", "len(X)-2*cnt", "len(X)", "len", "X", "2*cnt", "2", "cnt", "s += 1", "1", "s", "cnt += 1", "1", "cnt", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "def ZIP(n): return zip(*(MAP() for _ in range(n)))", "ZIP", "INF = float('inf')", "float('inf')", "INF", "def INT(): return int(input())", "def INT(): return int(input())", "INT", "cnt = 0", "0", "cnt", "X = input()", "input()", "X", "def LIST(): return list(map(int, input().split()))", "def LIST(): return list(map(int, input().split()))", "LIST", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "s = 0", "0", "s", "s -= 1", "1", "s", "def MAP(): return map(int, input().split())", "def MAP(): return map(int, input().split())", "MAP", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input" ]
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left, insort, insort_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 #mod = 998244353 from decimal import * #import numpy as np #decimal.getcontext().prec = 10 X = input() cnt = 0 s = 0 for i in range(len(X)): if X[i] == "S": s += 1 else: if 0 < s: cnt += 1 s -= 1 print(len(X)-2*cnt)
[ 7, 15, 13, 15, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 12, 4, 13, 4, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 18, 4, 18, 4, 13, 13, 13, 17, 12, 13, 0, 13, 18, 4, 13, 4, 13, 39, 17, 0, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 13, 0, 13, 4, 13, 17, 14, 2, 13, 17, 0, 13, 4, 13, 13, 13, 0, 13, 4, 13, 13, 13, 0, 13, 13, 0, 13, 2, 13, 2, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 18, 13, 10, 18, 13 ]
[ [ 169, 6 ], [ 172, 15 ], [ 160, 24 ], [ 173, 29 ], [ 154, 31 ], [ 173, 39 ], [ 163, 42 ], [ 173, 52 ], [ 157, 55 ], [ 170, 63 ], [ 151, 66 ], [ 173, 73 ], [ 81, 80 ], [ 152, 85 ], [ 90, 89 ], [ 80, 92 ], [ 95, 94 ], [ 80, 99 ], [ 102, 101 ], [ 105, 104 ], [ 112, 111 ], [ 121, 120 ], [ 104, 123 ], [ 132, 123 ], [ 126, 123 ], [ 111, 124 ], [ 127, 126 ], [ 104, 129 ], [ 132, 129 ], [ 126, 129 ], [ 111, 130 ], [ 133, 132 ], [ 111, 133 ], [ 136, 135 ], [ 89, 137 ], [ 120, 139 ], [ 101, 139 ], [ 135, 143 ], [ 167, 149 ], [ 151, 152 ], [ 154, 155 ], [ 157, 158 ], [ 160, 161 ], [ 163, 164 ], [ 169, 170 ], [ 172, 173 ] ]
[ "import sys\nimport itertools\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\nin_n = lambda: int(readline())\nin_nn = lambda: map(int, readline().split())\nin_nl = lambda: list(map(int, readline().split()))\nin_na = lambda: map(int, read().split())\nin_s = lambda: readline().rstrip().decode('utf-8')\n\n\ndef main():\n S = list(in_s())[::-1]\n N = len(S)\n\n gr = itertools.groupby(S)\n\n count = 0\n tnum = 0\n for k, v in gr:\n num = sum(1 for _ in v)\n if k == 'S':\n count += min(tnum, num)\n tnum -= min(tnum, num)\n else:\n tnum += num\n\n # print(count)\n\n ans = N - count * 2\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "import itertools", "itertools", "read = sys.stdin.buffer.read", "read", "sys.stdin.buffer.read", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "read", "readline = sys.stdin.buffer.readline", "readline", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "in_n = lambda: int(readline())", "in_n", "lambda: int(readline())", "int(readline())", "int", "readline()", "readline", "in_nn = lambda: map(int, readline().split())", "in_nn", "lambda: map(int, readline().split())", "map(int, readline().split())", "map", "int", "readline().split()", "().split", "()", "readline", "split", "in_nl = lambda: list(map(int, readline().split()))", "in_nl", "lambda: list(map(int, readline().split()))", "list(map(int, readline().split()))", "list", "map(int, readline().split())", "map", "int", "readline().split()", "().split", "()", "readline", "split", "in_na = lambda: map(int, read().split())", "in_na", "lambda: map(int, read().split())", "map(int, read().split())", "map", "int", "read().split()", "().split", "()", "read", "split", "in_s = lambda: readline().rstrip().decode('utf-8')", "in_s", "lambda: readline().rstrip().decode('utf-8')", "readline().rstrip().decode('utf-8')", "().rstrip().decode", "().rstrip()", "().rstrip", "()", "readline", "rstrip", "decode", "'utf-8'", "def main():\n S = list(in_s())[::-1]\n N = len(S)\n\n gr = itertools.groupby(S)\n\n count = 0\n tnum = 0\n for k, v in gr:\n num = sum(1 for _ in v)\n if k == 'S':\n count += min(tnum, num)\n tnum -= min(tnum, num)\n else:\n tnum += num\n\n # print(count)\n\n ans = N - count * 2\n print(ans)", "main", "S = list(in_s())[::-1]", "S", "list(in_s())[::-1]", "(in_s())", "list", "in_s()", "in_s", "::-1", "-1", "N = len(S)", "N", "len(S)", "len", "S", "gr = itertools.groupby(S)", "gr", "itertools.groupby(S)", "itertools.groupby", "itertools", "groupby", "S", "count = 0", "count", "0", "tnum = 0", "tnum", "0", "for k, v in gr:\n num = sum(1 for _ in v)\n if k == 'S':\n count += min(tnum, num)\n tnum -= min(tnum, num)\n else:\n tnum += num\n\n # print(count)\n\n ", "k", "v", "gr", "num = sum(1 for _ in v)", "num", "sum(1 for _ in v)", "sum", "1", "if k == 'S':\n count += min(tnum, num)\n tnum -= min(tnum, num)\n else:\n tnum += num\n\n # print(count)\n\n ", "k == 'S'", "k", "'S'", "count += min(tnum, num)", "count", "min(tnum, num)", "min", "tnum", "num", "tnum -= min(tnum, num)", "tnum", "min(tnum, num)", "min", "tnum", "num", "tnum += num", "tnum", "num", "ans = N - count * 2", "ans", "N - count * 2", "N", "count * 2", "count", "2", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "in_s = lambda: readline().rstrip().decode('utf-8')", "lambda: readline().rstrip().decode('utf-8')", "in_s", "in_nn = lambda: map(int, readline().split())", "lambda: map(int, readline().split())", "in_nn", "in_na = lambda: map(int, read().split())", "lambda: map(int, read().split())", "in_na", "in_n = lambda: int(readline())", "lambda: int(readline())", "in_n", "in_nl = lambda: list(map(int, readline().split()))", "lambda: list(map(int, readline().split()))", "in_nl", "def main():\n S = list(in_s())[::-1]\n N = len(S)\n\n gr = itertools.groupby(S)\n\n count = 0\n tnum = 0\n for k, v in gr:\n num = sum(1 for _ in v)\n if k == 'S':\n count += min(tnum, num)\n tnum -= min(tnum, num)\n else:\n tnum += num\n\n # print(count)\n\n ans = N - count * 2\n print(ans)", "def main():\n S = list(in_s())[::-1]\n N = len(S)\n\n gr = itertools.groupby(S)\n\n count = 0\n tnum = 0\n for k, v in gr:\n num = sum(1 for _ in v)\n if k == 'S':\n count += min(tnum, num)\n tnum -= min(tnum, num)\n else:\n tnum += num\n\n # print(count)\n\n ans = N - count * 2\n print(ans)", "main", "read = sys.stdin.buffer.read", "sys.stdin.buffer.read", "read", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline" ]
import sys import itertools read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline in_n = lambda: int(readline()) in_nn = lambda: map(int, readline().split()) in_nl = lambda: list(map(int, readline().split())) in_na = lambda: map(int, read().split()) in_s = lambda: readline().rstrip().decode('utf-8') def main(): S = list(in_s())[::-1] N = len(S) gr = itertools.groupby(S) count = 0 tnum = 0 for k, v in gr: num = sum(1 for _ in v) if k == 'S': count += min(tnum, num) tnum -= min(tnum, num) else: tnum += num # print(count) ans = N - count * 2 print(ans) if __name__ == '__main__': main()
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 40, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 46, 3 ], [ 49, 7 ], [ 12, 11 ], [ 47, 11 ], [ 11, 15 ], [ 50, 19 ], [ 11, 21 ], [ 50, 25 ], [ 50, 28 ], [ 50, 33 ], [ 50, 38 ], [ 50, 44 ], [ 46, 47 ], [ 49, 50 ] ]
[ "from collections import deque\nX = input()\n\nscan = deque()\n\nfor c in X:\n # print(scan)\n if c == 'S':\n scan.append(c)\n else:\n if not scan or scan[-1] == 'T':\n scan.append('T')\n else:\n scan.pop()\nprint(len(scan))", "from collections import deque", "X = input()", "X", "input()", "input", "scan = deque()", "scan", "deque()", "deque", "for c in X:\n # print(scan)\n if c == 'S':\n scan.append(c)\n else:\n if not scan or scan[-1] == 'T':\n scan.append('T')\n else:\n scan.pop()", "c", "X", "if c == 'S':\n scan.append(c)\n else:\n if not scan or scan[-1] == 'T':\n scan.append('T')\n else:\n scan.pop()", "c == 'S'", "c", "'S'", "scan.append(c)", "scan.append", "scan", "append", "c", "if not scan or scan[-1] == 'T':\n scan.append('T')\n else:\n scan.pop()", "not scan or scan[-1] == 'T'", "not scan", "scan", "scan[-1] == 'T'", "scan[-1]", "scan", "-1", "'T'", "scan.append('T')", "scan.append", "scan", "append", "'T'", "scan.pop()", "scan.pop", "scan", "pop", "print(len(scan))", "print", "len(scan)", "len", "scan", "X = input()", "input()", "X", "scan = deque()", "deque()", "scan" ]
from collections import deque X = input() scan = deque() for c in X: # print(scan) if c == 'S': scan.append(c) else: if not scan or scan[-1] == 'T': scan.append('T') else: scan.pop() print(len(scan))
[ 7, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 40, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 58, 2 ], [ 52, 14 ], [ 61, 17 ], [ 21, 20 ], [ 59, 20 ], [ 20, 24 ], [ 49, 27 ], [ 20, 32 ], [ 53, 35 ], [ 65, 35 ], [ 50, 35 ], [ 64, 38 ], [ 55, 41 ], [ 65, 46 ], [ 50, 46 ], [ 53, 46 ], [ 56, 47 ], [ 62, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "x = list(map(str, input().rstrip()))\n\nstock = 0\nrest = 0\nfor i in x:\n if i == \"S\":\n stock += 1\n elif i == \"T\" and stock >= 1:\n stock -= 1\n else:\n rest += 1\n\nprint(stock + rest)", "x = list(map(str, input().rstrip()))", "x", "list(map(str, input().rstrip()))", "list", "map(str, input().rstrip())", "map", "str", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "stock = 0", "stock", "0", "rest = 0", "rest", "0", "for i in x:\n if i == \"S\":\n stock += 1\n elif i == \"T\" and stock >= 1:\n stock -= 1\n else:\n rest += 1", "i", "x", "if i == \"S\":\n stock += 1\n elif i == \"T\" and stock >= 1:\n stock -= 1\n else:\n rest += 1", "i == \"S\"", "i", "\"S\"", "stock += 1", "stock", "1", "elif i == \"T\" and stock >= 1:\n stock -= 1\n ", "i == \"T\" and stock >= 1", "i == \"T\"", "i", "\"T\"", "stock >= 1", "stock", "1", "stock -= 1", "stock", "1", "rest += 1", "rest", "1", "print(stock + rest)", "print", "stock + rest", "stock", "rest", "stock += 1", "1", "stock", "stock = 0", "0", "stock", "rest += 1", "1", "rest", "x = list(map(str, input().rstrip()))", "list(map(str, input().rstrip()))", "x", "rest = 0", "0", "rest", "stock -= 1", "1", "stock" ]
x = list(map(str, input().rstrip())) stock = 0 rest = 0 for i in x: if i == "S": stock += 1 elif i == "T" and stock >= 1: stock -= 1 else: rest += 1 print(stock + rest)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 42, 2, 13, 2, 4, 13, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 9, 14, 2, 18, 13, 13, 17, 14, 2, 18, 13, 2, 13, 17, 17, 0, 13, 2, 18, 13, 39, 13, 18, 13, 39, 2, 13, 17, 0, 13, 17, 0, 13, 8, 40, 2, 13, 17, 17, 2, 13, 17, 17, 0, 13, 17, 4, 13, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 8, 13 ]
[ [ 98, 2 ], [ 80, 6 ], [ 95, 9 ], [ 96, 13 ], [ 90, 13 ], [ 102, 13 ], [ 84, 13 ], [ 99, 17 ], [ 93, 17 ], [ 99, 22 ], [ 93, 22 ], [ 96, 23 ], [ 90, 23 ], [ 102, 23 ], [ 84, 23 ], [ 83, 26 ], [ 99, 32 ], [ 93, 32 ], [ 84, 33 ], [ 96, 33 ], [ 90, 33 ], [ 102, 33 ], [ 99, 38 ], [ 93, 38 ], [ 84, 40 ], [ 96, 40 ], [ 90, 40 ], [ 102, 40 ], [ 92, 44 ], [ 99, 47 ], [ 93, 47 ], [ 99, 51 ], [ 93, 51 ], [ 84, 54 ], [ 96, 54 ], [ 90, 54 ], [ 102, 54 ], [ 86, 57 ], [ 101, 60 ], [ 84, 64 ], [ 96, 64 ], [ 90, 64 ], [ 102, 64 ], [ 84, 68 ], [ 96, 68 ], [ 90, 68 ], [ 102, 68 ], [ 89, 72 ], [ 93, 78 ], [ 99, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ] ]
[ "s = input()\n\nnow_try = 0\nidx = 0\nwhile idx < len(s) - 1:\n\n if s[idx] == 'T':\n idx += 1\n continue\n\n if s[idx] == 'S':\n if s[idx + 1] == 'T':\n s = s[:idx] + s[idx + 2:]\n now_try += 1\n idx = idx - 1 if idx - 1 >= 0 else 0\n else:\n idx += 1\n\nprint(len(s))", "s = input()", "s", "input()", "input", "now_try = 0", "now_try", "0", "idx = 0", "idx", "0", "while idx < len(s) - 1:\n\n if s[idx] == 'T':\n idx += 1\n continue\n\n if s[idx] == 'S':\n if s[idx + 1] == 'T':\n s = s[:idx] + s[idx + 2:]\n now_try += 1\n idx = idx - 1 if idx - 1 >= 0 else 0\n else:\n idx += 1", "idx < len(s) - 1", "idx", "len(s) - 1", "len(s)", "len", "s", "1", "if s[idx] == 'T':\n idx += 1\n continue\n\n ", "s[idx] == 'T'", "s[idx]", "s", "idx", "'T'", "idx += 1", "idx", "1", "continue", "if s[idx] == 'S':\n if s[idx + 1] == 'T':\n s = s[:idx] + s[idx + 2:]\n now_try += 1\n idx = idx - 1 if idx - 1 >= 0 else 0\n else:\n idx += 1", "s[idx] == 'S'", "s[idx]", "s", "idx", "'S'", "if s[idx + 1] == 'T':\n s = s[:idx] + s[idx + 2:]\n now_try += 1\n idx = idx - 1 if idx - 1 >= 0 else 0\n else:\n idx += 1", "s[idx + 1] == 'T'", "s[idx + 1]", "s", "idx + 1", "idx", "1", "'T'", "s = s[:idx] + s[idx + 2:]", "s", "s[:idx] + s[idx + 2:]", "s[:idx]", "s", ":idx", "idx", "s[idx + 2:]", "s", "idx + 2:", "idx + 2", "idx", "2", "now_try += 1", "now_try", "1", "idx = idx - 1 if idx - 1 >= 0 else 0", "idx", "idx - 1 if idx - 1 >= 0 else 0", "idx - 1 >= 0", "idx - 1", "idx", "1", "0", "idx - 1", "idx", "1", "0", "idx += 1", "idx", "1", "print(len(s))", "print", "len(s)", "len", "s", "now_try = 0", "0", "now_try", "idx += 1", "1", "idx", "now_try += 1", "1", "now_try", "idx += 1", "1", "idx", "s = s[:idx] + s[idx + 2:]", "s[:idx] + s[idx + 2:]", "s", "idx = 0", "0", "idx", "s = input()", "input()", "s", "idx = idx - 1 if idx - 1 >= 0 else 0", "idx - 1 if idx - 1 >= 0 else 0", "idx" ]
s = input() now_try = 0 idx = 0 while idx < len(s) - 1: if s[idx] == 'T': idx += 1 continue if s[idx] == 'S': if s[idx + 1] == 'T': s = s[:idx] + s[idx + 2:] now_try += 1 idx = idx - 1 if idx - 1 >= 0 else 0 else: idx += 1 print(len(s))
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 39, 18, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 18, 13, 13, 17, 14, 13, 0, 13, 4, 18, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 4, 18, 13, 13, 18, 13, 13, 4, 18, 13, 13, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 81, 3 ], [ 78, 7 ], [ 82, 12 ], [ 16, 15 ], [ 82, 21 ], [ 82, 25 ], [ 15, 26 ], [ 79, 30 ], [ 82, 33 ], [ 15, 34 ], [ 82, 38 ], [ 15, 39 ], [ 84, 44 ], [ 79, 47 ], [ 85, 51 ], [ 79, 55 ], [ 85, 57 ], [ 79, 60 ], [ 82, 63 ], [ 15, 64 ], [ 79, 67 ], [ 82, 70 ], [ 15, 71 ], [ 79, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ] ]
[ "from collections import deque\n\nX = input()\nstack = deque([X[0]])\nfor i in range(1, len(X)):\n if X[i] == 'S':\n stack.appendleft(X[i])\n\n if X[i] == 'T':\n if stack:\n check = stack.popleft()\n if check == 'T':\n stack.appendleft(check)\n stack.appendleft(X[i])\n else:\n stack.appendleft(X[i])\n\nprint(len(stack))", "from collections import deque", "X = input()", "X", "input()", "input", "stack = deque([X[0]])", "stack", "deque([X[0]])", "deque", "[X[0]]", "X[0]", "X", "0", "for i in range(1, len(X)):\n if X[i] == 'S':\n stack.appendleft(X[i])\n\n if X[i] == 'T':\n if stack:\n check = stack.popleft()\n if check == 'T':\n stack.appendleft(check)\n stack.appendleft(X[i])\n else:\n stack.appendleft(X[i])", "i", "range(1, len(X))", "range", "1", "len(X)", "len", "X", "if X[i] == 'S':\n stack.appendleft(X[i])\n\n ", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "stack.appendleft(X[i])", "stack.appendleft", "stack", "appendleft", "X[i]", "X", "i", "if X[i] == 'T':\n if stack:\n check = stack.popleft()\n if check == 'T':\n stack.appendleft(check)\n stack.appendleft(X[i])\n else:\n stack.appendleft(X[i])", "X[i] == 'T'", "X[i]", "X", "i", "'T'", "if stack:\n check = stack.popleft()\n if check == 'T':\n stack.appendleft(check)\n stack.appendleft(X[i])\n else:\n stack.appendleft(X[i])", "stack", "check = stack.popleft()", "check", "stack.popleft()", "stack.popleft", "stack", "popleft", "if check == 'T':\n stack.appendleft(check)\n stack.appendleft(X[i])\n ", "check == 'T'", "check", "'T'", "stack.appendleft(check)", "stack.appendleft", "stack", "appendleft", "check", "stack.appendleft(X[i])", "stack.appendleft", "stack", "appendleft", "X[i]", "X", "i", "stack.appendleft(X[i])", "stack.appendleft", "stack", "appendleft", "X[i]", "X", "i", "print(len(stack))", "print", "len(stack)", "len", "stack", "stack = deque([X[0]])", "deque([X[0]])", "stack", "X = input()", "input()", "X", "check = stack.popleft()", "stack.popleft()", "check" ]
from collections import deque X = input() stack = deque([X[0]]) for i in range(1, len(X)): if X[i] == 'S': stack.appendleft(X[i]) if X[i] == 'T': if stack: check = stack.popleft() if check == 'T': stack.appendleft(check) stack.appendleft(X[i]) else: stack.appendleft(X[i]) print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 17, 13, 17, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 65, 2 ], [ 59, 6 ], [ 68, 8 ], [ 53, 10 ], [ 14, 13 ], [ 66, 18 ], [ 66, 22 ], [ 54, 23 ], [ 57, 23 ], [ 47, 26 ], [ 60, 30 ], [ 63, 30 ], [ 48, 30 ], [ 62, 33 ], [ 50, 36 ], [ 56, 39 ], [ 51, 44 ], [ 69, 44 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "x = input()\nscount, tcount, c = 0, 0, 0\nfor i in range(len(x)):\n if x[c]==\"S\":\n scount+=1\n else:\n if scount>0:\n scount-=1\n else:\n tcount+=1\n c+=1\nprint(tcount*2)", "x = input()", "x", "input()", "input", "scount, tcount, c = 0, 0, 0", "scount", "0", "tcount", "0", "c", "0", "for i in range(len(x)):\n if x[c]==\"S\":\n scount+=1\n else:\n if scount>0:\n scount-=1\n else:\n tcount+=1\n c+=1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[c]==\"S\":\n scount+=1\n else:\n if scount>0:\n scount-=1\n else:\n tcount+=1\n ", "x[c]==\"S\"", "x[c]", "x", "c", "\"S\"", "scount+=1", "scount", "1", "if scount>0:\n scount-=1\n else:\n tcount+=1\n ", "scount>0", "scount", "0", "scount-=1", "scount", "1", "tcount+=1", "tcount", "1", "c+=1", "c", "1", "print(tcount*2)", "print", "tcount*2", "tcount", "2", "scount+=1", "1", "scount", "tcount+=1", "1", "tcount", "c = 0, 0, 0", "0", "c", "c+=1", "1", "c", "scount, tcount, c = 0, 0, 0", "0", "scount", "scount-=1", "1", "scount", "x = input()", "input()", "x", "tcount, c = 0, 0, 0", "0", "tcount" ]
x = input() scount, tcount, c = 0, 0, 0 for i in range(len(x)): if x[c]=="S": scount+=1 else: if scount>0: scount-=1 else: tcount+=1 c+=1 print(tcount*2)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 21, 22, 17, 17, 22, 17, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 18, 13, 18, 13, 13, 14, 2, 13, 13, 0, 13, 13, 4, 13, 2, 17, 13, 10, 21, 13, 10, 4, 13, 10, 17, 13, 10, 18, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 50, 2 ], [ 62, 6 ], [ 62, 9 ], [ 47, 12 ], [ 22, 21 ], [ 51, 26 ], [ 56, 28 ], [ 48, 30 ], [ 51, 32 ], [ 21, 33 ], [ 57, 36 ], [ 63, 36 ], [ 54, 37 ], [ 60, 37 ], [ 59, 39 ], [ 57, 40 ], [ 63, 40 ], [ 60, 45 ], [ 54, 45 ], [ 47, 48 ], [ 50, 51 ], [ 62, 54 ], [ 56, 57 ], [ 57, 59 ], [ 63, 59 ], [ 59, 60 ], [ 62, 63 ] ]
[ "# A - STring\n\nX = input()\ncount = max_count = 0\nST = {'S':-1, 'T':1}\n\nfor i in range(len(X)):\n count += ST[X[i]]\n if count > max_count:\n max_count = count\n\nprint(2*max_count)", "X = input()", "X", "input()", "input", "count = max_count = 0", "count", "0", "= max_count = 0", "max_count", "0", "ST = {'S':-1, 'T':1}", "ST", "{'S':-1, 'T':1}", "'S'", "'S'", "-1", "'T'", "'T'", "1", "for i in range(len(X)):\n count += ST[X[i]]\n if count > max_count:\n max_count = count", "i", "range(len(X))", "range", "len(X)", "len", "X", "count += ST[X[i]]", "count", "ST[X[i]]", "ST", "X[i]", "X", "i", "if count > max_count:\n max_count = count", "count > max_count", "count", "max_count", "max_count = count", "max_count", "count", "print(2*max_count)", "print", "2*max_count", "2", "max_count", "ST = {'S':-1, 'T':1}", "{'S':-1, 'T':1}", "ST", "X = input()", "input()", "X", "max_count = 0", "0", "max_count", "count += ST[X[i]]", "ST[X[i]]", "count", "max_count = count", "count", "max_count", "count = max_count = 0", "0", "count" ]
# A - STring X = input() count = max_count = 0 ST = {'S':-1, 'T':1} for i in range(len(X)): count += ST[X[i]] if count > max_count: max_count = count print(2*max_count)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 44, 2 ], [ 62, 6 ], [ 53, 9 ], [ 47, 12 ], [ 16, 15 ], [ 45, 20 ], [ 45, 24 ], [ 15, 25 ], [ 50, 28 ], [ 54, 32 ], [ 51, 32 ], [ 63, 33 ], [ 57, 33 ], [ 56, 35 ], [ 59, 38 ], [ 60, 42 ], [ 48, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "S = input()\n\nT_count = 0\nS_count = 0\nans = 0\nfor i in range(len(S)):\n if S[i] == \"S\":\n S_count += 1\n else:\n if S_count > T_count:\n T_count += 1\n else:\n ans += 2\n \nprint(ans)", "S = input()", "S", "input()", "input", "T_count = 0", "T_count", "0", "S_count = 0", "S_count", "0", "ans = 0", "ans", "0", "for i in range(len(S)):\n if S[i] == \"S\":\n S_count += 1\n else:\n if S_count > T_count:\n T_count += 1\n else:\n ans += 2\n ", "i", "range(len(S))", "range", "len(S)", "len", "S", "if S[i] == \"S\":\n S_count += 1\n else:\n if S_count > T_count:\n T_count += 1\n else:\n ans += 2\n ", "S[i] == \"S\"", "S[i]", "S", "i", "\"S\"", "S_count += 1", "S_count", "1", "if S_count > T_count:\n T_count += 1\n else:\n ans += 2\n ", "S_count > T_count", "S_count", "T_count", "T_count += 1", "T_count", "1", "ans += 2", "ans", "2", "print(ans)", "print", "ans", "S = input()", "input()", "S", "ans = 0", "0", "ans", "S_count += 1", "1", "S_count", "S_count = 0", "0", "S_count", "T_count += 1", "1", "T_count", "ans += 2", "2", "ans", "T_count = 0", "0", "T_count" ]
S = input() T_count = 0 S_count = 0 ans = 0 for i in range(len(S)): if S[i] == "S": S_count += 1 else: if S_count > T_count: T_count += 1 else: ans += 2 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 35, 2 ], [ 41, 6 ], [ 50, 9 ], [ 13, 12 ], [ 36, 12 ], [ 12, 16 ], [ 44, 19 ], [ 42, 23 ], [ 48, 23 ], [ 45, 23 ], [ 38, 26 ], [ 47, 29 ], [ 39, 33 ], [ 51, 33 ], [ 35, 36 ], [ 38, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ] ]
[ "x = input()\ns = 0\nans = 0\nfor c in x:\n if c == 'S':\n s += 1\n else:\n if s == 0:\n ans += 2\n else:\n s -= 1\nprint(ans)", "x = input()", "x", "input()", "input", "s = 0", "s", "0", "ans = 0", "ans", "0", "for c in x:\n if c == 'S':\n s += 1\n else:\n if s == 0:\n ans += 2\n else:\n s -= 1", "c", "x", "if c == 'S':\n s += 1\n else:\n if s == 0:\n ans += 2\n else:\n s -= 1", "c == 'S'", "c", "'S'", "s += 1", "s", "1", "if s == 0:\n ans += 2\n else:\n s -= 1", "s == 0", "s", "0", "ans += 2", "ans", "2", "s -= 1", "s", "1", "print(ans)", "print", "ans", "x = input()", "input()", "x", "ans += 2", "2", "ans", "s = 0", "0", "s", "s += 1", "1", "s", "s -= 1", "1", "s", "ans = 0", "0", "ans" ]
x = input() s = 0 ans = 0 for c in x: if c == 'S': s += 1 else: if s == 0: ans += 2 else: s -= 1 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 13, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 56, 2 ], [ 59, 6 ], [ 41, 9 ], [ 13, 12 ], [ 57, 12 ], [ 12, 16 ], [ 50, 19 ], [ 44, 22 ], [ 45, 26 ], [ 51, 26 ], [ 42, 26 ], [ 54, 26 ], [ 62, 29 ], [ 53, 32 ], [ 47, 35 ], [ 54, 36 ], [ 45, 36 ], [ 51, 36 ], [ 42, 36 ], [ 48, 39 ], [ 63, 39 ], [ 60, 39 ], [ 41, 42 ], [ 44, 45 ], [ 54, 47 ], [ 45, 47 ], [ 51, 47 ], [ 42, 47 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "s = input()\n\nans = 0\nnum = 0\nfor c in s:\n if c == 'T':\n num -= 1\n else:\n num += 1\n if num < 0:\n ans += 1\n num = 0\n\nans += num\nprint(ans)", "s = input()", "s", "input()", "input", "ans = 0", "ans", "0", "num = 0", "num", "0", "for c in s:\n if c == 'T':\n num -= 1\n else:\n num += 1\n if num < 0:\n ans += 1\n num = 0", "c", "s", "if c == 'T':\n num -= 1\n else:\n num += 1\n ", "c == 'T'", "c", "'T'", "num -= 1", "num", "1", "num += 1", "num", "1", "if num < 0:\n ans += 1\n num = 0", "num < 0", "num", "0", "ans += 1", "ans", "1", "num = 0", "num", "0", "ans += num", "ans", "num", "print(ans)", "print", "ans", "num = 0", "0", "num", "num += 1", "1", "num", "ans += num", "num", "ans", "num -= 1", "1", "num", "num = 0", "0", "num", "s = input()", "input()", "s", "ans = 0", "0", "ans", "ans += 1", "1", "ans" ]
s = input() ans = 0 num = 0 for c in s: if c == 'T': num -= 1 else: num += 1 if num < 0: ans += 1 num = 0 ans += num print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 54, 2 ], [ 51, 6 ], [ 45, 9 ], [ 13, 12 ], [ 55, 12 ], [ 12, 16 ], [ 42, 19 ], [ 48, 24 ], [ 39, 27 ], [ 55, 34 ], [ 49, 37 ], [ 52, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ] ]
[ "s = input()\nans = 0\ncnt = 0\nfor i in s:\n if i == \"S\":\n cnt += 1\n else:\n if cnt:\n ans += 1\n cnt -= 1\nprint(len(s) - (2*ans))", "s = input()", "s", "input()", "input", "ans = 0", "ans", "0", "cnt = 0", "cnt", "0", "for i in s:\n if i == \"S\":\n cnt += 1\n else:\n if cnt:\n ans += 1\n cnt -= 1", "i", "s", "if i == \"S\":\n cnt += 1\n else:\n if cnt:\n ans += 1\n cnt -= 1", "i == \"S\"", "i", "\"S\"", "cnt += 1", "cnt", "1", "if cnt:\n ans += 1\n cnt -= 1", "cnt", "ans += 1", "ans", "1", "cnt -= 1", "cnt", "1", "print(len(s) - (2*ans))", "print", "len(s) - (2*ans)", "len(s)", "len", "s", "2*ans", "2", "ans", "cnt -= 1", "1", "cnt", "cnt += 1", "1", "cnt", "cnt = 0", "0", "cnt", "ans += 1", "1", "ans", "ans = 0", "0", "ans", "s = input()", "input()", "s" ]
s = input() ans = 0 cnt = 0 for i in s: if i == "S": cnt += 1 else: if cnt: ans += 1 cnt -= 1 print(len(s) - (2*ans))
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 2, 13, 17, 2, 4, 13, 13, 17, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 64, 3 ], [ 67, 7 ], [ 12, 11 ], [ 65, 11 ], [ 11, 15 ], [ 68, 19 ], [ 11, 21 ], [ 11, 25 ], [ 68, 30 ], [ 68, 34 ], [ 11, 36 ], [ 68, 40 ], [ 68, 45 ], [ 11, 47 ], [ 68, 51 ], [ 68, 56 ], [ 68, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "from collections import deque\n\ns = input()\nq = deque()\n\nfor si in s:\n if si == \"S\":\n q.append(si)\n elif si == \"T\" and len(q) == 0:\n q.append(si)\n elif q[-1] == \"T\":\n q.append(si)\n elif q[-1] == \"S\":\n q.pop()\nprint(len(q))", "from collections import deque", "s = input()", "s", "input()", "input", "q = deque()", "q", "deque()", "deque", "for si in s:\n if si == \"S\":\n q.append(si)\n elif si == \"T\" and len(q) == 0:\n q.append(si)\n elif q[-1] == \"T\":\n q.append(si)\n elif q[-1] == \"S\":\n q.pop()", "si", "s", "if si == \"S\":\n q.append(si)\n elif si == \"T\" and len(q) == 0:\n q.append(si)\n elif q[-1] == \"T\":\n q.append(si)\n elif q[-1] == \"S\":\n q.pop()", "si == \"S\"", "si", "\"S\"", "q.append(si)", "q.append", "q", "append", "si", "elif si == \"T\" and len(q) == 0:\n q.append(si)\n ", "si == \"T\" and len(q) == 0", "si == \"T\"", "si", "\"T\"", "len(q) == 0", "len(q)", "len", "q", "0", "q.append(si)", "q.append", "q", "append", "si", "elif q[-1] == \"T\":\n q.append(si)\n ", "q[-1] == \"T\"", "q[-1]", "q", "-1", "\"T\"", "q.append(si)", "q.append", "q", "append", "si", "elif q[-1] == \"S\":\n q.pop()", "q[-1] == \"S\"", "q[-1]", "q", "-1", "\"S\"", "q.pop()", "q.pop", "q", "pop", "print(len(q))", "print", "len(q)", "len", "q", "s = input()", "input()", "s", "q = deque()", "deque()", "q" ]
from collections import deque s = input() q = deque() for si in s: if si == "S": q.append(si) elif si == "T" and len(q) == 0: q.append(si) elif q[-1] == "T": q.append(si) elif q[-1] == "S": q.pop() print(len(q))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 2, 13, 17, 14, 2, 13, 17, 4, 13, 2, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 38, 2 ], [ 32, 6 ], [ 39, 9 ], [ 35, 11 ], [ 15, 14 ], [ 39, 14 ], [ 36, 18 ], [ 14, 20 ], [ 14, 24 ], [ 36, 30 ], [ 32, 33 ], [ 35, 36 ], [ 38, 39 ] ]
[ "x=input()\nn=len(x)\ns=0\nfor i in x:\n if s and i=='T':s-=1\n if i=='S':s+=1\nprint(2*s)", "x=input()", "x", "input()", "input", "n=len(x)", "n", "len(x)", "len", "x", "s=0", "s", "0", "for i in x:\n if s and i=='T':s-=1\n if i=='S':s+=1", "i", "x", "if s and i=='T':s-=1\n ", "s and i=='T'", "s", "i=='T'", "i", "'T'", "if i=='S':s+", "i=='S'", "i", "'S'", "print(2*s)", "print", "2*s", "2", "s", "n=len(x)", "len(x)", "n", "s=0", "0", "s", "x=input()", "input()", "x" ]
x=input() n=len(x) s=0 for i in x: if s and i=='T':s-=1 if i=='S':s+=1 print(2*s)
[ 7, 15, 13, 15, 0, 13, 18, 18, 13, 13, 13, 12, 13, 0, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 2, 4, 13, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 13, 4, 18, 13, 13, 0, 13, 4, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 18, 13 ]
[ [ 75, 5 ], [ 15, 14 ], [ 76, 18 ], [ 22, 21 ], [ 26, 25 ], [ 14, 25 ], [ 25, 29 ], [ 21, 33 ], [ 25, 35 ], [ 21, 41 ], [ 21, 45 ], [ 21, 50 ], [ 25, 52 ], [ 21, 55 ], [ 59, 58 ], [ 21, 61 ], [ 58, 64 ], [ 73, 70 ], [ 75, 76 ] ]
[ "import sys\nfrom collections import deque\ninput = sys.stdin.readline\n\n\ndef main():\n X = input().rstrip()\n\n stack = deque()\n for s in X:\n if s == \"S\":\n stack.append(s)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(s)\n else:\n stack.pop()\n ans = len(stack)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "import sys", "sys", "from collections import deque", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def main():\n X = input().rstrip()\n\n stack = deque()\n for s in X:\n if s == \"S\":\n stack.append(s)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(s)\n else:\n stack.pop()\n ans = len(stack)\n print(ans)", "main", "X = input().rstrip()", "X", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "stack = deque()", "stack", "deque()", "deque", "for s in X:\n if s == \"S\":\n stack.append(s)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(s)\n else:\n stack.pop()\n ", "s", "X", "if s == \"S\":\n stack.append(s)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(s)\n else:\n stack.pop()\n ", "s == \"S\"", "s", "\"S\"", "stack.append(s)", "stack.append", "stack", "append", "s", "if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(s)\n else:\n stack.pop()\n ", "len(stack) == 0 or stack[-1] == \"T\"", "len(stack) == 0", "len(stack)", "len", "stack", "0", "stack[-1] == \"T\"", "stack[-1]", "stack", "-1", "\"T\"", "stack.append(s)", "stack.append", "stack", "append", "s", "stack.pop()", "stack.pop", "stack", "pop", "ans = len(stack)", "ans", "len(stack)", "len", "stack", "print(ans)", "print", "ans", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n X = input().rstrip()\n\n stack = deque()\n for s in X:\n if s == \"S\":\n stack.append(s)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(s)\n else:\n stack.pop()\n ans = len(stack)\n print(ans)", "def main():\n X = input().rstrip()\n\n stack = deque()\n for s in X:\n if s == \"S\":\n stack.append(s)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(s)\n else:\n stack.pop()\n ans = len(stack)\n print(ans)", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input" ]
import sys from collections import deque input = sys.stdin.readline def main(): X = input().rstrip() stack = deque() for s in X: if s == "S": stack.append(s) else: if len(stack) == 0 or stack[-1] == "T": stack.append(s) else: stack.pop() ans = len(stack) print(ans) if __name__ == "__main__": main()
[ 7, 15, 13, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 18, 13, 13, 4, 13, 17, 2, 17, 17, 0, 13, 12, 4, 18, 18, 13, 13, 13, 2, 13, 17, 23, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 2, 2, 13, 17, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 0, 13, 4, 13, 13, 4, 13, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 81, 4 ], [ 84, 26 ], [ 78, 39 ], [ 82, 41 ], [ 87, 43 ], [ 47, 46 ], [ 79, 46 ], [ 46, 52 ], [ 88, 54 ], [ 88, 57 ], [ 88, 62 ], [ 88, 66 ], [ 46, 68 ], [ 90, 70 ], [ 88, 73 ], [ 91, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ] ]
[ "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nx = input()\ns = []\nfor c in x:\n if c==\"T\" and s and s[-1]==\"S\":\n s.pop()\n else:\n s.append(c)\nans = len(s)\nprint(ans)", "import sys", "sys", "input = lambda : sys.stdin.readline().rstrip()", "input", "lambda : sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "sys.setrecursionlimit(max(1000, 10**9))", "sys.setrecursionlimit", "sys", "setrecursionlimit", "max(1000, 10**9)", "max", "1000", "10**9", "10", "9", "write = lambda x: sys.stdout.write(x+\"\\n\")", "write", "lambda x: sys.stdout.write(x+\"\\n\")", "sys.stdout.write(x+\"\\n\")", "sys.stdout.write", "sys.stdout", "sys", "stdout", "write", "x+\"\\n\"", "x", "\"\\n\"", "x", "x = input()", "x", "input()", "input", "s = []", "s", "[]", "for c in x:\n if c==\"T\" and s and s[-1]==\"S\":\n s.pop()\n else:\n s.append(c)", "c", "x", "if c==\"T\" and s and s[-1]==\"S\":\n s.pop()\n else:\n s.append(c)", "c==\"T\" and s and s[-1]==\"S\"", "c==\"T\" and s", "c==\"T\"", "c", "\"T\"", "s", "s[-1]==\"S\"", "s[-1]", "s", "-1", "\"S\"", "s.pop()", "s.pop", "s", "pop", "s.append(c)", "s.append", "s", "append", "c", "ans = len(s)", "ans", "len(s)", "len", "s", "print(ans)", "print", "ans", "x = input()", "input()", "x", "input = lambda : sys.stdin.readline().rstrip()", "lambda : sys.stdin.readline().rstrip()", "input", "write = lambda x: sys.stdout.write(x+\"\\n\")", "lambda x: sys.stdout.write(x+\"\\n\")", "write", "s = []", "[]", "s", "ans = len(s)", "len(s)", "ans" ]
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") x = input() s = [] for c in x: if c=="T" and s and s[-1]=="S": s.pop() else: s.append(c) ans = len(s) print(ans)
[ 7, 0, 13, 4, 13, 42, 2, 17, 13, 0, 13, 4, 18, 13, 13, 17, 17, 0, 13, 2, 4, 13, 13, 17, 14, 2, 40, 17, 18, 13, 39, 13, 40, 17, 18, 13, 39, 13, 0, 13, 17, 3, 4, 13, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 52, 8 ], [ 49, 8 ], [ 58, 8 ], [ 57, 10 ], [ 52, 13 ], [ 49, 13 ], [ 58, 13 ], [ 54, 18 ], [ 58, 22 ], [ 52, 22 ], [ 49, 22 ], [ 58, 29 ], [ 52, 29 ], [ 49, 29 ], [ 58, 35 ], [ 52, 35 ], [ 49, 35 ], [ 48, 39 ], [ 49, 46 ], [ 58, 46 ], [ 52, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "# TLE 1/13 corner0\nx = input()\nwhile 'ST' in x:\n x = x.replace('ST', '')\n # 以下の4行を加えて AC 'SSS..STTTTT..T' みたいなやつを検出\n n = len(x) // 2\n if ('T' not in x[:n]) and ('S' not in x[n:]):\n x = ''\n break\nprint(len(x))", "x = input()", "x", "input()", "input", "while 'ST' in x:\n x = x.replace('ST', '')\n # 以下の4行を加えて AC 'SSS..STTTTT..T' みたいなやつを検出\n n = len(x) // 2\n if ('T' not in x[:n]) and ('S' not in x[n:]):\n x = ''\n break", "'ST' in x", "'ST'", "x", "x = x.replace('ST', '')", "x", "x.replace('ST', '')", "x.replace", "x", "replace", "'ST'", "''", "n = len(x) // 2", "n", "len(x) // 2", "len(x)", "len", "x", "2", "if ('T' not in x[:n]) and ('S' not in x[n:]):\n x = ''\n break", "('T' not in x[:n]) and ('S' not in x[n:])", "'T' not in x[:n]", "'T'", "x[:n]", "x", ":n", "n", "'S' not in x[n:]", "'S'", "x[n:]", "x", "n:", "n", "x = ''", "x", "''", "break", "print(len(x))", "print", "len(x)", "len", "x", "x = ''", "''", "x", "x = input()", "input()", "x", "n = len(x) // 2", "len(x) // 2", "n", "x = x.replace('ST', '')", "x.replace('ST', '')", "x" ]
# TLE 1/13 corner0 x = input() while 'ST' in x: x = x.replace('ST', '') # 以下の4行を加えて AC 'SSS..STTTTT..T' みたいなやつを検出 n = len(x) // 2 if ('T' not in x[:n]) and ('S' not in x[n:]): x = '' break print(len(x))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 49, 2 ], [ 37, 6 ], [ 50, 9 ], [ 40, 11 ], [ 15, 14 ], [ 50, 14 ], [ 14, 18 ], [ 52, 21 ], [ 41, 25 ], [ 44, 25 ], [ 53, 25 ], [ 46, 28 ], [ 43, 31 ], [ 47, 35 ], [ 38, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "X = input()\nans = len(X)\nc = 0\n\nfor x in X:\n if x == 'S':\n c += 1\n else:\n if c > 0:\n ans -= 2\n c -= 1\nprint(ans)", "X = input()", "X", "input()", "input", "ans = len(X)", "ans", "len(X)", "len", "X", "c = 0", "c", "0", "for x in X:\n if x == 'S':\n c += 1\n else:\n if c > 0:\n ans -= 2\n c -= 1", "x", "X", "if x == 'S':\n c += 1\n else:\n if c > 0:\n ans -= 2\n c -= 1", "x == 'S'", "x", "'S'", "c += 1", "c", "1", "if c > 0:\n ans -= 2\n c -= 1", "c > 0", "c", "0", "ans -= 2", "ans", "2", "c -= 1", "c", "1", "print(ans)", "print", "ans", "ans = len(X)", "len(X)", "ans", "c = 0", "0", "c", "c -= 1", "1", "c", "ans -= 2", "2", "ans", "X = input()", "input()", "X", "c += 1", "1", "c" ]
X = input() ans = len(X) c = 0 for x in X: if x == 'S': c += 1 else: if c > 0: ans -= 2 c -= 1 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 51, 2 ], [ 39, 8 ], [ 45, 11 ], [ 15, 14 ], [ 52, 14 ], [ 14, 18 ], [ 46, 22 ], [ 55, 22 ], [ 49, 22 ], [ 48, 25 ], [ 42, 28 ], [ 54, 31 ], [ 43, 36 ], [ 40, 36 ], [ 55, 37 ], [ 49, 37 ], [ 46, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ] ]
[ "x = str(input())\ncnt = 0\ntmp = 0\nfor i in x:\n if i == 'T':\n if tmp > 0:\n tmp -= 1\n else:\n cnt += 1\n else:\n tmp += 1\nelse:\n print(cnt + tmp)", "x = str(input())", "x", "str(input())", "str", "input()", "input", "cnt = 0", "cnt", "0", "tmp = 0", "tmp", "0", "for i in x:\n if i == 'T':\n if tmp > 0:\n tmp -= 1\n else:\n cnt += 1\n else:\n tmp += 1\nelse:\n print(cnt + tmp)", "i", "x", "if i == 'T':\n if tmp > 0:\n tmp -= 1\n else:\n cnt += 1\n else:\n tmp += 1", "i == 'T'", "i", "'T'", "if tmp > 0:\n tmp -= 1\n else:\n cnt += 1\n ", "tmp > 0", "tmp", "0", "tmp -= 1", "tmp", "1", "cnt += 1", "cnt", "1", "tmp += 1", "tmp", "1", "print(cnt + tmp)", "print", "cnt + tmp", "cnt", "tmp", "cnt = 0", "0", "cnt", "cnt += 1", "1", "cnt", "tmp = 0", "0", "tmp", "tmp -= 1", "1", "tmp", "x = str(input())", "str(input())", "x", "tmp += 1", "1", "tmp" ]
x = str(input()) cnt = 0 tmp = 0 for i in x: if i == 'T': if tmp > 0: tmp -= 1 else: cnt += 1 else: tmp += 1 else: print(cnt + tmp)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 40, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 51, 2 ], [ 60, 6 ], [ 54, 9 ], [ 13, 12 ], [ 52, 12 ], [ 12, 16 ], [ 45, 19 ], [ 61, 24 ], [ 49, 24 ], [ 46, 24 ], [ 12, 27 ], [ 48, 30 ], [ 57, 33 ], [ 52, 40 ], [ 58, 43 ], [ 55, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "s = input()\nsnum = 0\nans = 0\nfor i in s:\n if(i=='S'):\n snum+=1\n elif(snum>=1 and i=='T'):\n snum -=1\n ans +=1\nprint(len(s)-2*ans)", "s = input()", "s", "input()", "input", "snum = 0", "snum", "0", "ans = 0", "ans", "0", "for i in s:\n if(i=='S'):\n snum+=1\n elif(snum>=1 and i=='T'):\n snum -=1\n ans +=1", "i", "s", "if(i=='S'):\n snum+=1\n elif(snum>=1 and i=='T'):\n snum -=1\n ans +=1", "i=='S'", "i", "'S'", "snum+=1", "snum", "1", "elif(snum>=1 and i=='T'):\n snum -=1\n ans +=1", "snum>=1 and i=='T'", "snum>=1", "snum", "1", "i=='T'", "i", "'T'", "snum -=1", "snum", "1", "ans +=1", "ans", "1", "print(len(s)-2*ans)", "print", "len(s)-2*ans", "len(s)", "len", "s", "2*ans", "2", "ans", "snum+=1", "1", "snum", "snum -=1", "1", "snum", "s = input()", "input()", "s", "ans = 0", "0", "ans", "ans +=1", "1", "ans", "snum = 0", "0", "snum" ]
s = input() snum = 0 ans = 0 for i in s: if(i=='S'): snum+=1 elif(snum>=1 and i=='T'): snum -=1 ans +=1 print(len(s)-2*ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 52, 2 ], [ 37, 6 ], [ 40, 9 ], [ 13, 12 ], [ 53, 12 ], [ 12, 16 ], [ 46, 19 ], [ 38, 23 ], [ 44, 23 ], [ 47, 23 ], [ 43, 26 ], [ 49, 29 ], [ 50, 34 ], [ 41, 34 ], [ 44, 35 ], [ 47, 35 ], [ 38, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "X = input()\n\ncntS = 0\nres = 0\nfor x in X:\n if x == \"S\":\n cntS += 1\n elif cntS > 0:\n cntS -= 1\n else:\n res += 1\n\nprint(res + cntS)", "X = input()", "X", "input()", "input", "cntS = 0", "cntS", "0", "res = 0", "res", "0", "for x in X:\n if x == \"S\":\n cntS += 1\n elif cntS > 0:\n cntS -= 1\n else:\n res += 1", "x", "X", "if x == \"S\":\n cntS += 1\n elif cntS > 0:\n cntS -= 1\n else:\n res += 1", "x == \"S\"", "x", "\"S\"", "cntS += 1", "cntS", "1", "elif cntS > 0:\n cntS -= 1\n ", "cntS > 0", "cntS", "0", "cntS -= 1", "cntS", "1", "res += 1", "res", "1", "print(res + cntS)", "print", "res + cntS", "res", "cntS", "cntS = 0", "0", "cntS", "res = 0", "0", "res", "cntS -= 1", "1", "cntS", "cntS += 1", "1", "cntS", "res += 1", "1", "res", "X = input()", "input()", "X" ]
X = input() cntS = 0 res = 0 for x in X: if x == "S": cntS += 1 elif cntS > 0: cntS -= 1 else: res += 1 print(res + cntS)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 18, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 69, 3 ], [ 72, 7 ], [ 70, 10 ], [ 75, 12 ], [ 17, 16 ], [ 73, 19 ], [ 70, 23 ], [ 16, 24 ], [ 76, 28 ], [ 70, 31 ], [ 16, 32 ], [ 76, 37 ], [ 76, 41 ], [ 70, 44 ], [ 16, 45 ], [ 76, 49 ], [ 76, 54 ], [ 70, 57 ], [ 16, 58 ], [ 76, 61 ], [ 76, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "from collections import deque\n\ns = input()\nn = len(s)\nque = deque()\nfor i in range(n):\n if s[i] == 'S':\n que.append(s[i])\n else:\n if len(que) == 0:\n que.append(s[i])\n elif que[-1] == 'T':\n que.append(s[i])\n else:\n que.pop()\n \nprint(len(que))", "from collections import deque", "s = input()", "s", "input()", "input", "n = len(s)", "n", "len(s)", "len", "s", "que = deque()", "que", "deque()", "deque", "for i in range(n):\n if s[i] == 'S':\n que.append(s[i])\n else:\n if len(que) == 0:\n que.append(s[i])\n elif que[-1] == 'T':\n que.append(s[i])\n else:\n que.pop()\n ", "i", "range(n)", "range", "n", "if s[i] == 'S':\n que.append(s[i])\n else:\n if len(que) == 0:\n que.append(s[i])\n elif que[-1] == 'T':\n que.append(s[i])\n else:\n que.pop()\n ", "s[i] == 'S'", "s[i]", "s", "i", "'S'", "que.append(s[i])", "que.append", "que", "append", "s[i]", "s", "i", "if len(que) == 0:\n que.append(s[i])\n elif que[-1] == 'T':\n que.append(s[i])\n else:\n que.pop()\n ", "len(que) == 0", "len(que)", "len", "que", "0", "que.append(s[i])", "que.append", "que", "append", "s[i]", "s", "i", "elif que[-1] == 'T':\n que.append(s[i])\n ", "que[-1] == 'T'", "que[-1]", "que", "-1", "'T'", "que.append(s[i])", "que.append", "que", "append", "s[i]", "s", "i", "que.pop()", "que.pop", "que", "pop", "print(len(que))", "print", "len(que)", "len", "que", "s = input()", "input()", "s", "n = len(s)", "len(s)", "n", "que = deque()", "deque()", "que" ]
from collections import deque s = input() n = len(s) que = deque() for i in range(n): if s[i] == 'S': que.append(s[i]) else: if len(que) == 0: que.append(s[i]) elif que[-1] == 'T': que.append(s[i]) else: que.pop() print(len(que))
[ 7, 0, 13, 4, 13, 0, 13, 2, 39, 17, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 40, 18, 13, 13, 14, 2, 18, 13, 39, 13, 2, 13, 17, 17, 0, 13, 17, 0, 18, 13, 2, 13, 17, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 2, 18, 13, 13, 17, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 91, 2 ], [ 109, 6 ], [ 92, 12 ], [ 100, 14 ], [ 88, 17 ], [ 94, 20 ], [ 24, 23 ], [ 92, 28 ], [ 110, 32 ], [ 23, 33 ], [ 92, 37 ], [ 23, 41 ], [ 85, 45 ], [ 53, 48 ], [ 110, 49 ], [ 23, 51 ], [ 92, 57 ], [ 23, 58 ], [ 103, 61 ], [ 92, 67 ], [ 23, 68 ], [ 89, 70 ], [ 98, 70 ], [ 104, 70 ], [ 106, 72 ], [ 97, 75 ], [ 92, 82 ], [ 107, 83 ], [ 86, 83 ], [ 101, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ], [ 100, 101 ], [ 103, 104 ], [ 106, 107 ], [ 109, 110 ] ]
[ "x = input()\nvisited = [0]*(len(x))\nans = 0\ns = 0\nt = 0\nfor i in range(len(x)):\n if not visited[i]:\n if x[i:i+2] == \"ST\":\n ans += 2\n visited[i+1] = 1\n elif x[i] == \"S\":\n s += 1\n elif x[i] == \"T\" and s:\n ans += 2\n s -= 1\nprint(len(x)-ans)", "x = input()", "x", "input()", "input", "visited = [0]*(len(x))", "visited", "[0]*(len(x))", "[0]", "0", "len(x)", "len", "x", "ans = 0", "ans", "0", "s = 0", "s", "0", "t = 0", "t", "0", "for i in range(len(x)):\n if not visited[i]:\n if x[i:i+2] == \"ST\":\n ans += 2\n visited[i+1] = 1\n elif x[i] == \"S\":\n s += 1\n elif x[i] == \"T\" and s:\n ans += 2\n s -= 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if not visited[i]:\n if x[i:i+2] == \"ST\":\n ans += 2\n visited[i+1] = 1\n elif x[i] == \"S\":\n s += 1\n elif x[i] == \"T\" and s:\n ans += 2\n s -= 1", "not visited[i]", "visited[i]", "visited", "i", "if x[i:i+2] == \"ST\":\n ans += 2\n visited[i+1] = 1\n elif x[i] == \"S\":\n s += 1\n elif x[i] == \"T\" and s:\n ans += 2\n s -= 1", "x[i:i+2] == \"ST\"", "x[i:i+2]", "x", "i:i+2", "i", "i+2", "i", "2", "\"ST\"", "ans += 2", "ans", "2", "visited[i+1] = 1", "visited[i+1]", "visited", "i+1", "i", "1", "1", "elif x[i] == \"S\":\n s += 1\n ", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "s += 1", "s", "1", "elif x[i] == \"T\" and s:\n ans += 2\n s -= 1", "x[i] == \"T\" and s", "x[i] == \"T\"", "x[i]", "x", "i", "\"T\"", "s", "ans += 2", "ans", "2", "s -= 1", "s", "1", "print(len(x)-ans)", "print", "len(x)-ans", "len(x)", "len", "x", "ans", "ans += 2", "2", "ans", "s = 0", "0", "s", "x = input()", "input()", "x", "t = 0", "0", "t", "s -= 1", "1", "s", "ans = 0", "0", "ans", "s += 1", "1", "s", "ans += 2", "2", "ans", "visited = [0]*(len(x))", "[0]*(len(x))", "visited" ]
x = input() visited = [0]*(len(x)) ans = 0 s = 0 t = 0 for i in range(len(x)): if not visited[i]: if x[i:i+2] == "ST": ans += 2 visited[i+1] = 1 elif x[i] == "S": s += 1 elif x[i] == "T" and s: ans += 2 s -= 1 print(len(x)-ans)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 56, 2 ], [ 41, 6 ], [ 57, 9 ], [ 44, 11 ], [ 15, 14 ], [ 57, 14 ], [ 14, 18 ], [ 47, 21 ], [ 48, 26 ], [ 45, 26 ], [ 54, 26 ], [ 14, 29 ], [ 53, 32 ], [ 50, 35 ], [ 51, 39 ], [ 42, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "x=input()\nans=len(x)\np=0\nfor i in x:\n if i==\"S\":\n p+=1\n if p>0 and i==\"T\":\n p-=1\n ans-=2\nprint(ans)", "x=input()", "x", "input()", "input", "ans=len(x)", "ans", "len(x)", "len", "x", "p=0", "p", "0", "for i in x:\n if i==\"S\":\n p+=1\n if p>0 and i==\"T\":\n p-=1\n ans-=2", "i", "x", "if i==\"S\":\n p+=1\n ", "i==\"S\"", "i", "\"S\"", "p+=1", "p", "1", "if p>0 and i==\"T\":\n p-=1\n ans-=2", "p>0 and i==\"T\"", "p>0", "p", "0", "i==\"T\"", "i", "\"T\"", "p-=1", "p", "1", "ans-=2", "ans", "2", "print(ans)", "print", "ans", "ans=len(x)", "len(x)", "ans", "p=0", "0", "p", "p+=1", "1", "p", "ans-=2", "2", "ans", "p-=1", "1", "p", "x=input()", "input()", "x" ]
x=input() ans=len(x) p=0 for i in x: if i=="S": p+=1 if p>0 and i=="T": p-=1 ans-=2 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 59, 2 ], [ 68, 6 ], [ 47, 9 ], [ 56, 12 ], [ 16, 15 ], [ 60, 15 ], [ 15, 19 ], [ 50, 22 ], [ 48, 26 ], [ 66, 26 ], [ 51, 26 ], [ 62, 29 ], [ 53, 32 ], [ 65, 35 ], [ 60, 42 ], [ 63, 45 ], [ 57, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "w = input()\n\nmode = 1\nc_s = 0\nans = 0\n\nfor i in w:\n# print(i)\n if i == 'S':\n c_s += 1\n else:\n if c_s > 0:\n ans += 1\n mode = 1\n c_s -= 1\n\nprint(len(w)-(2*ans))", "w = input()", "w", "input()", "input", "mode = 1", "mode", "1", "c_s = 0", "c_s", "0", "ans = 0", "ans", "0", "for i in w:\n# print(i)\n if i == 'S':\n c_s += 1\n else:\n if c_s > 0:\n ans += 1\n mode = 1\n c_s -= 1", "i", "w", "if i == 'S':\n c_s += 1\n else:\n if c_s > 0:\n ans += 1\n mode = 1\n c_s -= 1", "i == 'S'", "i", "'S'", "c_s += 1", "c_s", "1", "if c_s > 0:\n ans += 1\n mode = 1\n c_s -= 1", "c_s > 0", "c_s", "0", "ans += 1", "ans", "1", "mode = 1", "mode", "1", "c_s -= 1", "c_s", "1", "print(len(w)-(2*ans))", "print", "len(w)-(2*ans)", "len(w)", "len", "w", "2*ans", "2", "ans", "c_s = 0", "0", "c_s", "c_s += 1", "1", "c_s", "mode = 1", "1", "mode", "ans = 0", "0", "ans", "w = input()", "input()", "w", "ans += 1", "1", "ans", "c_s -= 1", "1", "c_s", "mode = 1", "1", "mode" ]
w = input() mode = 1 c_s = 0 ans = 0 for i in w: # print(i) if i == 'S': c_s += 1 else: if c_s > 0: ans += 1 mode = 1 c_s -= 1 print(len(w)-(2*ans))
[ 7, 12, 13, 15, 13, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 19, 18 ], [ 6, 20 ], [ 23, 22 ], [ 18, 25 ], [ 28, 27 ], [ 31, 30 ], [ 34, 33 ], [ 22, 36 ], [ 18, 40 ], [ 33, 41 ], [ 45, 44 ], [ 50, 49 ], [ 53, 52 ], [ 22, 57 ], [ 52, 58 ], [ 30, 58 ], [ 67, 64 ] ]
[ "def main():\n #input data\n import sys\n input = lambda:sys.stdin.readline().strip()\n S = input()\n \n #solve\n N = len(S)\n cnt=0\n ans=0\n for i in range(N):\n if S[i]=='S':\n cnt+=1\n else:\n if cnt:\n cnt-=1\n ans+=2\n print(N-ans)\n\n\nif __name__=='__main__':\n main()", "def main():\n #input data\n import sys\n input = lambda:sys.stdin.readline().strip()\n S = input()\n \n #solve\n N = len(S)\n cnt=0\n ans=0\n for i in range(N):\n if S[i]=='S':\n cnt+=1\n else:\n if cnt:\n cnt-=1\n ans+=2\n print(N-ans)", "main", "import sys", "sys", "input = lambda:sys.stdin.readline().strip()", "input", "lambda:sys.stdin.readline().strip()", "sys.stdin.readline().strip()", "sys.stdin.readline().strip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "strip", "S = input()", "S", "input()", "input", "N = len(S)", "N", "len(S)", "len", "S", "cnt=0", "cnt", "0", "ans=0", "ans", "0", "for i in range(N):\n if S[i]=='S':\n cnt+=1\n else:\n if cnt:\n cnt-=1\n ans+=2\n ", "i", "range(N)", "range", "N", "if S[i]=='S':\n cnt+=1\n else:\n if cnt:\n cnt-=1\n ans+=2\n ", "S[i]=='S'", "S[i]", "S", "i", "'S'", "cnt+=1", "cnt", "1", "if cnt:\n cnt-=1\n ans+=2\n ", "cnt", "cnt-=1", "cnt", "1", "ans+=2", "ans", "2", "print(N-ans)", "print", "N-ans", "N", "ans", "if __name__=='__main__':\n main()", "__name__=='__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n #input data\n import sys\n input = lambda:sys.stdin.readline().strip()\n S = input()\n \n #solve\n N = len(S)\n cnt=0\n ans=0\n for i in range(N):\n if S[i]=='S':\n cnt+=1\n else:\n if cnt:\n cnt-=1\n ans+=2\n print(N-ans)", "def main():\n #input data\n import sys\n input = lambda:sys.stdin.readline().strip()\n S = input()\n \n #solve\n N = len(S)\n cnt=0\n ans=0\n for i in range(N):\n if S[i]=='S':\n cnt+=1\n else:\n if cnt:\n cnt-=1\n ans+=2\n print(N-ans)", "main" ]
def main(): #input data import sys input = lambda:sys.stdin.readline().strip() S = input() #solve N = len(S) cnt=0 ans=0 for i in range(N): if S[i]=='S': cnt+=1 else: if cnt: cnt-=1 ans+=2 print(N-ans) if __name__=='__main__': main()
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 17, 14, 2, 13, 4, 13, 39, 4, 18, 13, 13, 17, 0, 13, 4, 18, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 17, 4, 18, 13, 13, 17, 9, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 75, 3 ], [ 78, 7 ], [ 76, 10 ], [ 69, 12 ], [ 17, 16 ], [ 79, 19 ], [ 76, 23 ], [ 16, 24 ], [ 70, 28 ], [ 70, 33 ], [ 70, 39 ], [ 72, 43 ], [ 70, 46 ], [ 73, 50 ], [ 70, 54 ], [ 70, 59 ], [ 70, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "from collections import deque\nx = input()\nn = len(x)\nst = deque()\n\nfor i in range(n):\n if x[i] == \"S\":\n st.append(\"S\")\n else:\n if st == deque([]):\n st.append(\"T\")\n else:\n a = st.pop()\n if a == \"T\":\n st.append(\"T\")\n st.append(\"T\")\n else:\n continue\n \nprint(len(st))", "from collections import deque", "x = input()", "x", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "st = deque()", "st", "deque()", "deque", "for i in range(n):\n if x[i] == \"S\":\n st.append(\"S\")\n else:\n if st == deque([]):\n st.append(\"T\")\n else:\n a = st.pop()\n if a == \"T\":\n st.append(\"T\")\n st.append(\"T\")\n else:\n continue\n ", "i", "range(n)", "range", "n", "if x[i] == \"S\":\n st.append(\"S\")\n else:\n if st == deque([]):\n st.append(\"T\")\n else:\n a = st.pop()\n if a == \"T\":\n st.append(\"T\")\n st.append(\"T\")\n else:\n continue\n ", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "st.append(\"S\")", "st.append", "st", "append", "\"S\"", "if st == deque([]):\n st.append(\"T\")\n else:\n a = st.pop()\n if a == \"T\":\n st.append(\"T\")\n st.append(\"T\")\n else:\n continue\n ", "st == deque([])", "st", "deque([])", "deque", "[]", "st.append(\"T\")", "st.append", "st", "append", "\"T\"", "a = st.pop()", "a", "st.pop()", "st.pop", "st", "pop", "if a == \"T\":\n st.append(\"T\")\n st.append(\"T\")\n else:\n continue\n ", "a == \"T\"", "a", "\"T\"", "st.append(\"T\")", "st.append", "st", "append", "\"T\"", "st.append(\"T\")", "st.append", "st", "append", "\"T\"", "continue", "print(len(st))", "print", "len(st)", "len", "st", "st = deque()", "deque()", "st", "a = st.pop()", "st.pop()", "a", "x = input()", "input()", "x", "n = len(x)", "len(x)", "n" ]
from collections import deque x = input() n = len(x) st = deque() for i in range(n): if x[i] == "S": st.append("S") else: if st == deque([]): st.append("T") else: a = st.pop() if a == "T": st.append("T") st.append("T") else: continue print(len(st))
[ 7, 15, 0, 13, 4, 13, 39, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 13, 17, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 68, 3 ], [ 65, 8 ], [ 13, 12 ], [ 66, 12 ], [ 12, 16 ], [ 69, 20 ], [ 12, 22 ], [ 12, 25 ], [ 69, 31 ], [ 69, 35 ], [ 12, 37 ], [ 69, 41 ], [ 69, 46 ], [ 12, 48 ], [ 69, 52 ], [ 69, 57 ], [ 69, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "# https://atcoder.jp/contests/agc005/tasks/agc005_a\n#\n# Stackでやる\n\nfrom collections import deque\n\nstack = deque([])\nX = input()\n\nfor ch in X:\n if ch == 'S':\n stack.append(ch)\n elif ch == 'T':\n if len(stack) == 0:\n stack.append(ch)\n elif stack[-1] == 'T':\n stack.append(ch)\n elif stack[-1] == 'S':\n stack.pop()\n\nprint(len(stack))", "from collections import deque", "stack = deque([])", "stack", "deque([])", "deque", "[]", "X = input()", "X", "input()", "input", "for ch in X:\n if ch == 'S':\n stack.append(ch)\n elif ch == 'T':\n if len(stack) == 0:\n stack.append(ch)\n elif stack[-1] == 'T':\n stack.append(ch)\n elif stack[-1] == 'S':\n stack.pop()", "ch", "X", "if ch == 'S':\n stack.append(ch)\n elif ch == 'T':\n if len(stack) == 0:\n stack.append(ch)\n elif stack[-1] == 'T':\n stack.append(ch)\n elif stack[-1] == 'S':\n stack.pop()", "ch == 'S'", "ch", "'S'", "stack.append(ch)", "stack.append", "stack", "append", "ch", "elif ch == 'T':\n if len(stack) == 0:\n stack.append(ch)\n elif stack[-1] == 'T':\n stack.append(ch)\n elif stack[-1] == 'S':\n stack.pop()", "ch == 'T'", "ch", "'T'", "if len(stack) == 0:\n stack.append(ch)\n elif stack[-1] == 'T':\n stack.append(ch)\n elif stack[-1] == 'S':\n stack.pop()", "len(stack) == 0", "len(stack)", "len", "stack", "0", "stack.append(ch)", "stack.append", "stack", "append", "ch", "elif stack[-1] == 'T':\n stack.append(ch)\n ", "stack[-1] == 'T'", "stack[-1]", "stack", "-1", "'T'", "stack.append(ch)", "stack.append", "stack", "append", "ch", "elif stack[-1] == 'S':\n stack.pop()", "stack[-1] == 'S'", "stack[-1]", "stack", "-1", "'S'", "stack.pop()", "stack.pop", "stack", "pop", "print(len(stack))", "print", "len(stack)", "len", "stack", "X = input()", "input()", "X", "stack = deque([])", "deque([])", "stack" ]
# https://atcoder.jp/contests/agc005/tasks/agc005_a # # Stackでやる from collections import deque stack = deque([]) X = input() for ch in X: if ch == 'S': stack.append(ch) elif ch == 'T': if len(stack) == 0: stack.append(ch) elif stack[-1] == 'T': stack.append(ch) elif stack[-1] == 'S': stack.pop() print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 73, 2 ], [ 64, 6 ], [ 55, 9 ], [ 61, 12 ], [ 16, 15 ], [ 74, 20 ], [ 74, 24 ], [ 15, 25 ], [ 76, 28 ], [ 74, 33 ], [ 15, 34 ], [ 70, 37 ], [ 77, 41 ], [ 65, 41 ], [ 68, 41 ], [ 58, 44 ], [ 67, 47 ], [ 59, 52 ], [ 71, 52 ], [ 56, 52 ], [ 68, 53 ], [ 77, 53 ], [ 65, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "s = input()\ns_cnt =0\nt_cnt =0\ncnt = 0\n\nfor i in range(len(s)):\n if s[i] == 'S':\n s_cnt += 1\n if s[i] == 'T':\n t_cnt += 1\n if s_cnt >0:\n t_cnt -= 1\n s_cnt -= 1\nprint(t_cnt + s_cnt)", "s = input()", "s", "input()", "input", "s_cnt =0", "s_cnt", "0", "t_cnt =0", "t_cnt", "0", "cnt = 0", "cnt", "0", "for i in range(len(s)):\n if s[i] == 'S':\n s_cnt += 1\n if s[i] == 'T':\n t_cnt += 1\n if s_cnt >0:\n t_cnt -= 1\n s_cnt -= 1", "i", "range(len(s))", "range", "len(s)", "len", "s", "if s[i] == 'S':\n s_cnt += 1\n ", "s[i] == 'S'", "s[i]", "s", "i", "'S'", "s_cnt += 1", "s_cnt", "1", "if s[i] == 'T':\n t_cnt += 1\n if s_cnt >0:\n t_cnt -= 1\n s_cnt -= 1", "s[i] == 'T'", "s[i]", "s", "i", "'T'", "t_cnt += 1", "t_cnt", "1", "if s_cnt >0:\n t_cnt -= 1\n s_cnt -= 1", "s_cnt >0", "s_cnt", "0", "t_cnt -= 1", "t_cnt", "1", "s_cnt -= 1", "s_cnt", "1", "print(t_cnt + s_cnt)", "print", "t_cnt + s_cnt", "t_cnt", "s_cnt", "t_cnt =0", "0", "t_cnt", "t_cnt -= 1", "1", "t_cnt", "cnt = 0", "0", "cnt", "s_cnt =0", "0", "s_cnt", "s_cnt -= 1", "1", "s_cnt", "t_cnt += 1", "1", "t_cnt", "s = input()", "input()", "s", "s_cnt += 1", "1", "s_cnt" ]
s = input() s_cnt =0 t_cnt =0 cnt = 0 for i in range(len(s)): if s[i] == 'S': s_cnt += 1 if s[i] == 'T': t_cnt += 1 if s_cnt >0: t_cnt -= 1 s_cnt -= 1 print(t_cnt + s_cnt)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 0, 13, 17, 0, 13, 4, 13, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 71, 2 ], [ 68, 6 ], [ 72, 9 ], [ 59, 11 ], [ 62, 14 ], [ 18, 17 ], [ 69, 20 ], [ 72, 24 ], [ 17, 25 ], [ 60, 29 ], [ 72, 32 ], [ 17, 33 ], [ 60, 38 ], [ 60, 42 ], [ 65, 45 ], [ 56, 48 ], [ 60, 51 ], [ 57, 54 ], [ 66, 54 ], [ 63, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "X=input()\nN=len(X)\nstack=[]\nans=0\n\nfor i in range(N):\n if X[i]==\"S\":\n stack.append(X[i])\n else:\n if len(stack)>0:\n stack.pop()\n else:\n ans += 1\nans += len(stack)\n\nprint(ans)", "X=input()", "X", "input()", "input", "N=len(X)", "N", "len(X)", "len", "X", "stack=[]", "stack", "[]", "ans=0", "ans", "0", "for i in range(N):\n if X[i]==\"S\":\n stack.append(X[i])\n else:\n if len(stack)>0:\n stack.pop()\n else:\n ans += 1", "i", "range(N)", "range", "N", "if X[i]==\"S\":\n stack.append(X[i])\n else:\n if len(stack)>0:\n stack.pop()\n else:\n ans += 1", "X[i]==\"S\"", "X[i]", "X", "i", "\"S\"", "stack.append(X[i])", "stack.append", "stack", "append", "X[i]", "X", "i", "if len(stack)>0:\n stack.pop()\n else:\n ans += 1", "len(stack)>0", "len(stack)", "len", "stack", "0", "stack.pop()", "stack.pop", "stack", "pop", "ans += 1", "ans", "1", "ans += len(stack)", "ans", "len(stack)", "len", "stack", "print(ans)", "print", "ans", "ans += len(stack)", "len(stack)", "ans", "stack=[]", "[]", "stack", "ans=0", "0", "ans", "ans += 1", "1", "ans", "N=len(X)", "len(X)", "N", "X=input()", "input()", "X" ]
X=input() N=len(X) stack=[] ans=0 for i in range(N): if X[i]=="S": stack.append(X[i]) else: if len(stack)>0: stack.pop() else: ans += 1 ans += len(stack) print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 13, 2, 4, 13, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 87, 2 ], [ 90, 6 ], [ 84, 8 ], [ 88, 12 ], [ 63, 15 ], [ 69, 18 ], [ 22, 21 ], [ 88, 21 ], [ 21, 25 ], [ 66, 28 ], [ 85, 33 ], [ 79, 33 ], [ 70, 34 ], [ 82, 34 ], [ 76, 34 ], [ 72, 37 ], [ 75, 40 ], [ 81, 43 ], [ 70, 48 ], [ 82, 48 ], [ 76, 48 ], [ 78, 51 ], [ 88, 58 ], [ 73, 60 ], [ 64, 60 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ] ]
[ "X = input()\n\ns, t = 0, len(X)//2\ncnt = 0\nused = 0\nfor x in X:\n if x == 'S':\n s += 1\n if t-used > 0:\n cnt += 1\n used += 1\n else:\n used = max(0, used-1)\n t -= 1\n\nprint(len(X)-cnt*2)", "X = input()", "X", "input()", "input", "s, t = 0, len(X)//2", "s", "0", "t", "len(X)//2", "len(X)", "len", "X", "2", "cnt = 0", "cnt", "0", "used = 0", "used", "0", "for x in X:\n if x == 'S':\n s += 1\n if t-used > 0:\n cnt += 1\n used += 1\n else:\n used = max(0, used-1)\n t -= 1", "x", "X", "if x == 'S':\n s += 1\n if t-used > 0:\n cnt += 1\n used += 1\n else:\n used = max(0, used-1)\n t -= 1", "x == 'S'", "x", "'S'", "s += 1", "s", "1", "if t-used > 0:\n cnt += 1\n used += 1\n ", "t-used > 0", "t-used", "t", "used", "0", "cnt += 1", "cnt", "1", "used += 1", "used", "1", "used = max(0, used-1)", "used", "max(0, used-1)", "max", "0", "used-1", "used", "1", "t -= 1", "t", "1", "print(len(X)-cnt*2)", "print", "len(X)-cnt*2", "len(X)", "len", "X", "cnt*2", "cnt", "2", "cnt = 0", "0", "cnt", "s += 1", "1", "s", "used = 0", "0", "used", "cnt += 1", "1", "cnt", "used += 1", "1", "used", "t -= 1", "1", "t", "used = max(0, used-1)", "max(0, used-1)", "used", "t = 0, len(X)//2", "len(X)//2", "t", "X = input()", "input()", "X", "s, t = 0, len(X)//2", "0", "s" ]
X = input() s, t = 0, len(X)//2 cnt = 0 used = 0 for x in X: if x == 'S': s += 1 if t-used > 0: cnt += 1 used += 1 else: used = max(0, used-1) t -= 1 print(len(X)-cnt*2)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 2, 18, 13, 13, 17, 13, 0, 13, 17, 4, 18, 13, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 52, 2 ], [ 61, 6 ], [ 53, 9 ], [ 55, 11 ], [ 15, 14 ], [ 53, 19 ], [ 53, 23 ], [ 14, 24 ], [ 56, 28 ], [ 53, 31 ], [ 14, 32 ], [ 53, 37 ], [ 14, 38 ], [ 56, 40 ], [ 58, 42 ], [ 56, 46 ], [ 59, 50 ], [ 62, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "# https://atcoder.jp/contests/agc005/tasks/agc005_a\n\nx = input()\nans = len(x)\nstack = []\nfor i in range(len(x)):\n if x[i] == 'S':\n stack.append(x[i])\n elif x[i] == 'T' and stack:\n ans -= 2\n stack.pop()\nprint(ans)", "x = input()", "x", "input()", "input", "ans = len(x)", "ans", "len(x)", "len", "x", "stack = []", "stack", "[]", "for i in range(len(x)):\n if x[i] == 'S':\n stack.append(x[i])\n elif x[i] == 'T' and stack:\n ans -= 2\n stack.pop()", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == 'S':\n stack.append(x[i])\n elif x[i] == 'T' and stack:\n ans -= 2\n stack.pop()", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "stack.append(x[i])", "stack.append", "stack", "append", "x[i]", "x", "i", "elif x[i] == 'T' and stack:\n ans -= 2\n stack.pop()", "x[i] == 'T' and stack", "x[i] == 'T'", "x[i]", "x", "i", "'T'", "stack", "ans -= 2", "ans", "2", "stack.pop()", "stack.pop", "stack", "pop", "print(ans)", "print", "ans", "x = input()", "input()", "x", "stack = []", "[]", "stack", "ans -= 2", "2", "ans", "ans = len(x)", "len(x)", "ans" ]
# https://atcoder.jp/contests/agc005/tasks/agc005_a x = input() ans = len(x) stack = [] for i in range(len(x)): if x[i] == 'S': stack.append(x[i]) elif x[i] == 'T' and stack: ans -= 2 stack.pop() print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 13, 9, 14, 2, 2, 18, 13, 17, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 46, 2 ], [ 49, 6 ], [ 10, 9 ], [ 47, 9 ], [ 50, 15 ], [ 50, 19 ], [ 9, 21 ], [ 50, 27 ], [ 9, 29 ], [ 50, 33 ], [ 50, 37 ], [ 9, 39 ], [ 50, 44 ], [ 46, 47 ], [ 49, 50 ] ]
[ "string = input()\nstack = []\nfor c in string:\n if len(stack) == 0:\n stack.append(c)\n continue\n if stack[-1] + c == 'ST':\n stack.pop()\n else:\n stack.append(c)\n\nprint(len(stack))", "string = input()", "string", "input()", "input", "stack = []", "stack", "[]", "for c in string:\n if len(stack) == 0:\n stack.append(c)\n continue\n if stack[-1] + c == 'ST':\n stack.pop()\n else:\n stack.append(c)", "c", "string", "if len(stack) == 0:\n stack.append(c)\n continue\n ", "len(stack) == 0", "len(stack)", "len", "stack", "0", "stack.append(c)", "stack.append", "stack", "append", "c", "continue", "if stack[-1] + c == 'ST':\n stack.pop()\n else:\n stack.append(c)", "stack[-1] + c == 'ST'", "stack[-1] + c", "stack[-1]", "stack", "-1", "c", "'ST'", "stack.pop()", "stack.pop", "stack", "pop", "stack.append(c)", "stack.append", "stack", "append", "c", "print(len(stack))", "print", "len(stack)", "len", "stack", "string = input()", "input()", "string", "stack = []", "[]", "stack" ]
string = input() stack = [] for c in string: if len(stack) == 0: stack.append(c) continue if stack[-1] + c == 'ST': stack.pop() else: stack.append(c) print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 13, 4, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 43, 2 ], [ 46, 6 ], [ 40, 9 ], [ 13, 12 ], [ 44, 12 ], [ 12, 16 ], [ 41, 20 ], [ 12, 22 ], [ 41, 27 ], [ 49, 30 ], [ 50, 35 ], [ 47, 35 ], [ 41, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ] ]
[ "X = input()\nnum_t = 0\nstack = []\nfor x in X:\n if x == 'S':\n stack.append(x)\n else:\n if stack:\n stack.pop()\n else:\n num_t += 1\n\nprint(num_t + len(stack))", "X = input()", "X", "input()", "input", "num_t = 0", "num_t", "0", "stack = []", "stack", "[]", "for x in X:\n if x == 'S':\n stack.append(x)\n else:\n if stack:\n stack.pop()\n else:\n num_t += 1", "x", "X", "if x == 'S':\n stack.append(x)\n else:\n if stack:\n stack.pop()\n else:\n num_t += 1", "x == 'S'", "x", "'S'", "stack.append(x)", "stack.append", "stack", "append", "x", "if stack:\n stack.pop()\n else:\n num_t += 1", "stack", "stack.pop()", "stack.pop", "stack", "pop", "num_t += 1", "num_t", "1", "print(num_t + len(stack))", "print", "num_t + len(stack)", "num_t", "len(stack)", "len", "stack", "stack = []", "[]", "stack", "X = input()", "input()", "X", "num_t = 0", "0", "num_t", "num_t += 1", "1", "num_t" ]
X = input() num_t = 0 stack = [] for x in X: if x == 'S': stack.append(x) else: if stack: stack.pop() else: num_t += 1 print(num_t + len(stack))
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 12, 13, 0, 13, 4, 13, 0, 13, 17, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 29, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 17, 16 ], [ 21, 20 ], [ 23, 22 ], [ 26, 25 ], [ 16, 25 ], [ 25, 29 ], [ 33, 32 ], [ 20, 36 ], [ 42, 36 ], [ 32, 36 ], [ 40, 39 ], [ 43, 42 ], [ 42, 47 ], [ 32, 47 ], [ 20, 47 ], [ 39, 48 ], [ 22, 48 ], [ 59, 56 ] ]
[ "import numpy as np\nimport functools\nimport math\nimport scipy\nimport fractions\nimport itertools\n \ndef solve():\n x = input()\n a, b = 0, 0\n for i in x:\n if i == \"S\":\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1\n print(a + b)\n return 0\n\nif __name__ == \"__main__\":\n solve()", "import numpy as np", "numpy", "import functools", "functools", "import math", "math", "import scipy", "scipy", "import fractions", "fractions", "import itertools", "itertools", "def solve():\n x = input()\n a, b = 0, 0\n for i in x:\n if i == \"S\":\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1\n print(a + b)\n return 0", "solve", "x = input()", "x", "input()", "input", "a, b = 0, 0", "a", "0", "b", "0", "for i in x:\n if i == \"S\":\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1\n ", "i", "x", "if i == \"S\":\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1\n ", "i == \"S\"", "i", "\"S\"", "a += 1", "a", "1", "if a == 0:\n b += 1\n else:\n a -= 1\n ", "a == 0", "a", "0", "b += 1", "b", "1", "a -= 1", "a", "1", "print(a + b)", "print", "a + b", "a", "b", "return 0", "0", "if __name__ == \"__main__\":\n solve()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "solve()", "solve", "def solve():\n x = input()\n a, b = 0, 0\n for i in x:\n if i == \"S\":\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1\n print(a + b)\n return 0", "def solve():\n x = input()\n a, b = 0, 0\n for i in x:\n if i == \"S\":\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1\n print(a + b)\n return 0", "solve" ]
import numpy as np import functools import math import scipy import fractions import itertools def solve(): x = input() a, b = 0, 0 for i in x: if i == "S": a += 1 else: if a == 0: b += 1 else: a -= 1 print(a + b) return 0 if __name__ == "__main__": solve()
[ 7, 15, 0, 13, 4, 13, 0, 13, 39, 13, 39, 0, 13, 4, 13, 13, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 0, 13, 17, 13, 17, 28, 13, 13, 14, 2, 2, 4, 13, 13, 13, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 17, 13, 10, 39, 13, 10, 17, 13, 10, 39, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 86, 3 ], [ 68, 7 ], [ 74, 9 ], [ 80, 12 ], [ 87, 15 ], [ 18, 17 ], [ 81, 20 ], [ 87, 24 ], [ 17, 25 ], [ 69, 29 ], [ 17, 31 ], [ 75, 34 ], [ 17, 36 ], [ 77, 38 ], [ 71, 40 ], [ 44, 43 ], [ 75, 43 ], [ 69, 50 ], [ 43, 51 ], [ 72, 52 ], [ 90, 52 ], [ 83, 55 ], [ 89, 58 ], [ 81, 63 ], [ 84, 66 ], [ 78, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ] ]
[ "from bisect import bisect_left\nx=input()\ns,t=[],[]\nn=len(x)\nfor i in range(n):\n if x[i]==\"S\":\n s.append(i)\n else:\n t.append(i)\nans,cnt=0,0\n#print(t)\nfor idx in t:\n if bisect_left(s,idx)-cnt>0:\n ans+=1\n cnt+=1\nprint(n-2*ans)", "from bisect import bisect_left", "x=input()", "x", "input()", "input", "s,t=[],[]", "s", "[]", "t", "[]", "n=len(x)", "n", "len(x)", "len", "x", "for i in range(n):\n if x[i]==\"S\":\n s.append(i)\n else:\n t.append(i)", "i", "range(n)", "range", "n", "if x[i]==\"S\":\n s.append(i)\n else:\n t.append(i)", "x[i]==\"S\"", "x[i]", "x", "i", "\"S\"", "s.append(i)", "s.append", "s", "append", "i", "t.append(i)", "t.append", "t", "append", "i", "ans,cnt=0,0", "ans", "0", "cnt", "0", "for idx in t:\n if bisect_left(s,idx)-cnt>0:\n ans+=1\n cnt+=1", "idx", "t", "if bisect_left(s,idx)-cnt>0:\n ans+=1\n cnt+=1", "bisect_left(s,idx)-cnt>0", "bisect_left(s,idx)-cnt", "bisect_left(s,idx)", "bisect_left", "s", "idx", "cnt", "0", "ans+=1", "ans", "1", "cnt+=1", "cnt", "1", "print(n-2*ans)", "print", "n-2*ans", "n", "2*ans", "2", "ans", "s,t=[],[]", "[]", "s", "cnt=0,0", "0", "cnt", "t=[],[]", "[]", "t", "ans,cnt=0,0", "0", "ans", "n=len(x)", "len(x)", "n", "ans+=1", "1", "ans", "x=input()", "input()", "x", "cnt+=1", "1", "cnt" ]
from bisect import bisect_left x=input() s,t=[],[] n=len(x) for i in range(n): if x[i]=="S": s.append(i) else: t.append(i) ans,cnt=0,0 #print(t) for idx in t: if bisect_left(s,idx)-cnt>0: ans+=1 cnt+=1 print(n-2*ans)
[ 7, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 31, 2 ], [ 31, 5 ], [ 9, 8 ], [ 8, 13 ], [ 34, 16 ], [ 29, 20 ], [ 35, 20 ], [ 35, 25 ], [ 29, 25 ], [ 32, 26 ], [ 31, 29 ], [ 31, 32 ], [ 34, 35 ] ]
[ "s=t=0\nfor i in input():\n if i==\"S\":\n s+=1\n elif s>0:s-=1\n else:t+=1\nprint(s+t)", "s=t=0", "s", "0", "=t=0", "t", "0", "for i in input():\n if i==\"S\":\n s+=1\n elif s>0:s-=1\n else:t+=1", "i", "input()", "input", "if i==\"S\":\n s+=1\n elif s>0:s-=1\n else:t+=1", "i==\"S\"", "i", "\"S\"", "s+=1", "s", "1", "elif s>0:s-=1\n ", "s>0", "s", "0", "print(s+t)", "print", "s+t", "s", "t", "s=t=0", "0", "s", "t=0", "0", "t", "s+=1", "1", "s" ]
s=t=0 for i in input(): if i=="S": s+=1 elif s>0:s-=1 else:t+=1 print(s+t)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 2, 13, 17, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 2, 17, 13, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 73, 2 ], [ 64, 8 ], [ 67, 11 ], [ 15, 14 ], [ 74, 19 ], [ 65, 23 ], [ 62, 23 ], [ 71, 23 ], [ 74, 27 ], [ 14, 28 ], [ 76, 31 ], [ 65, 37 ], [ 62, 37 ], [ 71, 37 ], [ 74, 40 ], [ 14, 41 ], [ 70, 44 ], [ 74, 49 ], [ 14, 50 ], [ 61, 53 ], [ 62, 58 ], [ 71, 58 ], [ 65, 58 ], [ 77, 59 ], [ 68, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "X=list(input())\n\ncounter_s = 0\n\ncounter_t = 0\n\nfor i in range(len(X)):\n if counter_s == 0 and X[i] == 'T':\n counter_t += 1\n elif 0 < counter_s and X[i] == 'T':\n counter_s -= 1\n elif X[i] == 'S':\n counter_s += 1\nprint(counter_s+counter_t)", "X=list(input())", "X", "list(input())", "list", "input()", "input", "counter_s = 0", "counter_s", "0", "counter_t = 0", "counter_t", "0", "for i in range(len(X)):\n if counter_s == 0 and X[i] == 'T':\n counter_t += 1\n elif 0 < counter_s and X[i] == 'T':\n counter_s -= 1\n elif X[i] == 'S':\n counter_s += 1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if counter_s == 0 and X[i] == 'T':\n counter_t += 1\n elif 0 < counter_s and X[i] == 'T':\n counter_s -= 1\n elif X[i] == 'S':\n counter_s += 1", "counter_s == 0 and X[i] == 'T'", "counter_s == 0", "counter_s", "0", "X[i] == 'T'", "X[i]", "X", "i", "'T'", "counter_t += 1", "counter_t", "1", "elif 0 < counter_s and X[i] == 'T':\n counter_s -= 1\n ", "0 < counter_s and X[i] == 'T'", "0 < counter_s", "0", "counter_s", "X[i] == 'T'", "X[i]", "X", "i", "'T'", "counter_s -= 1", "counter_s", "1", "elif X[i] == 'S':\n counter_s += 1", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "counter_s += 1", "counter_s", "1", "print(counter_s+counter_t)", "print", "counter_s+counter_t", "counter_s", "counter_t", "counter_s += 1", "1", "counter_s", "counter_s = 0", "0", "counter_s", "counter_t = 0", "0", "counter_t", "counter_s -= 1", "1", "counter_s", "X=list(input())", "list(input())", "X", "counter_t += 1", "1", "counter_t" ]
X=list(input()) counter_s = 0 counter_t = 0 for i in range(len(X)): if counter_s == 0 and X[i] == 'T': counter_t += 1 elif 0 < counter_s and X[i] == 'T': counter_s -= 1 elif X[i] == 'S': counter_s += 1 print(counter_s+counter_t)
[ 7, 15, 13, 0, 13, 39, 17, 17, 17, 0, 13, 17, 0, 13, 18, 13, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 4, 13, 0, 13, 17, 12, 13, 0, 13, 18, 4, 13, 4, 13, 39, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 29, 2, 4, 13, 13, 13, 0, 13, 17, 12, 13, 14, 13, 4, 13, 13, 23, 13, 12, 13, 15, 13, 0, 13, 4, 18, 13, 13, 0, 13, 4, 18, 13, 13, 28, 13, 13, 27, 13, 14, 2, 13, 17, 14, 2, 18, 13, 13, 17, 14, 2, 13, 18, 13, 17, 0, 13, 4, 13, 0, 13, 12, 4, 18, 13, 13, 14, 2, 13, 18, 13, 17, 0, 18, 13, 13, 4, 13, 17, 0, 13, 17, 0, 13, 18, 18, 13, 13, 13, 0, 13, 4, 13, 14, 40, 13, 17, 4, 13, 13, 10, 12, 13, 10, 18, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 17, 13, 10, 18, 13, 10, 12, 13, 10, 17, 13, 10, 39, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 206, 4 ], [ 203, 10 ], [ 197, 13 ], [ 207, 15 ], [ 204, 16 ], [ 212, 18 ], [ 185, 29 ], [ 182, 36 ], [ 42, 41 ], [ 51, 50 ], [ 54, 53 ], [ 57, 56 ], [ 41, 56 ], [ 56, 60 ], [ 64, 63 ], [ 50, 67 ], [ 70, 67 ], [ 63, 67 ], [ 71, 70 ], [ 74, 73 ], [ 41, 79 ], [ 73, 80 ], [ 53, 80 ], [ 191, 82 ], [ 92, 90 ], [ 92, 92 ], [ 99, 98 ], [ 105, 104 ], [ 98, 107 ], [ 111, 110 ], [ 104, 110 ], [ 110, 113 ], [ 198, 126 ], [ 207, 128 ], [ 215, 131 ], [ 201, 133 ], [ 188, 135 ], [ 216, 139 ], [ 198, 143 ], [ 207, 145 ], [ 151, 148 ], [ 194, 155 ], [ 179, 158 ], [ 218, 165 ], [ 210, 167 ], [ 219, 170 ], [ 219, 174 ], [ 179, 180 ], [ 182, 183 ], [ 185, 186 ], [ 188, 189 ], [ 191, 192 ], [ 194, 195 ], [ 197, 198 ], [ 203, 204 ], [ 206, 207 ], [ 212, 213 ], [ 215, 216 ], [ 218, 219 ] ]
[ "import sys\n\ninput_methods=['clipboard','file','key']\nusing_method=1\ninput_method=input_methods[using_method]\n\ntin=lambda : map(int, input().split())\nlin=lambda : list(IN())\nmod=1000000007\n\n#+++++\n\ndef main():\n\t#a = int(input())\n\t#b , c = tin()\n\ts = list(input())[:-1]\n\n\tcount_s = 0\n\tdelete_num=0\n\tfor c in s:\n\t\tif c == 'S':\n\t\t\tcount_s+=1\n\t\telse: #if c == 'T':\n\t\t\tif count_s == 0:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount_s-=1\n\t\t\t\tdelete_num+=2\n\treturn len(s)-delete_num\n\t\n\t\n#+++++\nisTest=False\n\ndef pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t\ndef input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l\n\nif __name__ == \"__main__\":\n\tif sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\tinput = sys.stdin.readline\n\t\t\t\n\tret = main()\n\tif ret is not None:\n\t\tprint(ret)", "import sys", "sys", "input_methods=['clipboard','file','key']", "input_methods", "['clipboard','file','key']", "'clipboard'", "'file'", "'key'", "using_method=1", "using_method", "1", "input_method=input_methods[using_method]", "input_method", "input_methods[using_method]", "input_methods", "using_method", "tin=lambda : map(int, input().split())", "tin", "lambda : map(int, input().split())", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "lin=lambda : list(IN())", "lin", "lambda : list(IN())", "list(IN())", "list", "IN()", "IN", "mod=1000000007", "mod", "1000000007", "def main():\n\t#a = int(input())\n\t#b , c = tin()\n\ts = list(input())[:-1]\n\n\tcount_s = 0\n\tdelete_num=0\n\tfor c in s:\n\t\tif c == 'S':\n\t\t\tcount_s+=1\n\t\telse: #if c == 'T':\n\t\t\tif count_s == 0:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount_s-=1\n\t\t\t\tdelete_num+=2\n\treturn len(s)-delete_num\n\t\n\t\n#+++++", "main", "s = list(input())[:-1]", "s", "list(input())[:-1]", "(input())", "list", "input()", "input", ":-1", "-1", "count_s = 0", "count_s", "0", "delete_num=0", "delete_num", "0", "for c in s:\n\t\tif c == 'S':\n\t\t\tcount_s+=1\n\t\telse: #if c == 'T':\n\t\t\tif count_s == 0:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount_s-=1\n\t\t\t\tdelete_num+=2\n\t", "c", "s", "if c == 'S':\n\t\t\tcount_s+=1\n\t\telse: #if c == 'T':\n\t\t\tif count_s == 0:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount_s-=1\n\t\t\t\tdelete_num+=2\n\t", "c == 'S'", "c", "'S'", "count_s+=1", "count_s", "1", "if count_s == 0:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount_s-=1\n\t\t\t\tdelete_num+=2\n\t", "count_s == 0", "count_s", "0", "count_s-=1", "count_s", "1", "delete_num+=2", "delete_num", "2", "return len(s)-delete_num", "len(s)-delete_num", "len(s)", "len", "s", "delete_num", "isTest=False", "isTest", "False", "def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t", "pa", "if isTest:\n\t\tprint(v)\n\t\t", "isTest", "print(v)", "print", "v", "v", "v", "def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l", "input_clipboard", "import clipboard", "clipboard", "input_text=clipboard.get()", "input_text", "clipboard.get()", "clipboard.get", "clipboard", "get", "input_l=input_text.splitlines()", "input_l", "input_text.splitlines()", "input_text.splitlines", "input_text", "splitlines", "for l in input_l:\n\t\tyield l", "l", "input_l", "yield l", "l", "if __name__ == \"__main__\":\n\tif sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\tinput = sys.stdin.readline\n\t\t\t\n\tret = main()\n\tif ret is not None:\n\t\tprint(ret)", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "if sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\tinput = sys.stdin.readline\n\t\t\t\n\t", "sys.platform =='ios'", "sys.platform", "sys", "platform", "'ios'", "if input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\t", "input_method==input_methods[0]", "input_method", "input_methods[0]", "input_methods", "0", "ic=input_clipboard()", "ic", "input_clipboard()", "input_clipboard", "input = lambda : ic.__next__()", "input", "lambda : ic.__next__()", "ic.__next__()", "ic.__next__", "ic", "__next__", "elif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\t", "input_method==input_methods[1]", "input_method", "input_methods[1]", "input_methods", "1", "sys.stdin=open('inputFile.txt')", "sys.stdin", "sys", "stdin", "open('inputFile.txt')", "open", "'inputFile.txt'", "isTest=True", "isTest", "True", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "ret = main()", "ret", "main()", "main", "if ret is not None:\n\t\tprint(ret)", "ret is not None", "ret", "None", "print(ret)", "print", "ret", "def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t", "def pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t", "pa", "input = sys.stdin.readline", "sys.stdin.readline", "input", "mod=1000000007", "1000000007", "mod", "lin=lambda : list(IN())", "lambda : list(IN())", "lin", "input = lambda : ic.__next__()", "lambda : ic.__next__()", "input", "isTest=False", "False", "isTest", "isTest=True", "True", "isTest", "input_method=input_methods[using_method]", "input_methods[using_method]", "input_method", "def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l", "def input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l", "input_clipboard", "using_method=1", "1", "using_method", "input_methods=['clipboard','file','key']", "['clipboard','file','key']", "input_methods", "def main():\n\t#a = int(input())\n\t#b , c = tin()\n\ts = list(input())[:-1]\n\n\tcount_s = 0\n\tdelete_num=0\n\tfor c in s:\n\t\tif c == 'S':\n\t\t\tcount_s+=1\n\t\telse: #if c == 'T':\n\t\t\tif count_s == 0:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount_s-=1\n\t\t\t\tdelete_num+=2\n\treturn len(s)-delete_num\n\t\n\t\n#+++++", "def main():\n\t#a = int(input())\n\t#b , c = tin()\n\ts = list(input())[:-1]\n\n\tcount_s = 0\n\tdelete_num=0\n\tfor c in s:\n\t\tif c == 'S':\n\t\t\tcount_s+=1\n\t\telse: #if c == 'T':\n\t\t\tif count_s == 0:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount_s-=1\n\t\t\t\tdelete_num+=2\n\treturn len(s)-delete_num\n\t\n\t\n#+++++", "main", "tin=lambda : map(int, input().split())", "lambda : map(int, input().split())", "tin", "ic=input_clipboard()", "input_clipboard()", "ic", "ret = main()", "main()", "ret" ]
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] count_s = 0 delete_num=0 for c in s: if c == 'S': count_s+=1 else: #if c == 'T': if count_s == 0: pass else: count_s-=1 delete_num+=2 return len(s)-delete_num #+++++ 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)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 65, 2 ], [ 50, 8 ], [ 53, 10 ], [ 62, 13 ], [ 17, 16 ], [ 66, 21 ], [ 66, 25 ], [ 16, 26 ], [ 68, 29 ], [ 51, 33 ], [ 60, 33 ], [ 57, 33 ], [ 56, 36 ], [ 71, 39 ], [ 59, 42 ], [ 60, 47 ], [ 57, 47 ], [ 51, 47 ], [ 72, 48 ], [ 69, 48 ], [ 54, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "x = list(input())\ns, t = 0, 0\nans = 0\nfor i in range(len(x)):\n if x[i] == \"T\":\n t += 1\n if s > 0:\n s -= 1\n t -= 1\n else:\n s += 1\nprint(s + t)", "x = list(input())", "x", "list(input())", "list", "input()", "input", "s, t = 0, 0", "s", "0", "t", "0", "ans = 0", "ans", "0", "for i in range(len(x)):\n if x[i] == \"T\":\n t += 1\n if s > 0:\n s -= 1\n t -= 1\n else:\n s += 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == \"T\":\n t += 1\n if s > 0:\n s -= 1\n t -= 1\n else:\n s += 1", "x[i] == \"T\"", "x[i]", "x", "i", "\"T\"", "t += 1", "t", "1", "if s > 0:\n s -= 1\n t -= 1\n ", "s > 0", "s", "0", "s -= 1", "s", "1", "t -= 1", "t", "1", "s += 1", "s", "1", "print(s + t)", "print", "s + t", "s", "t", "s, t = 0, 0", "0", "s", "t = 0, 0", "0", "t", "s -= 1", "1", "s", "s += 1", "1", "s", "ans = 0", "0", "ans", "x = list(input())", "list(input())", "x", "t += 1", "1", "t", "t -= 1", "1", "t" ]
x = list(input()) s, t = 0, 0 ans = 0 for i in range(len(x)): if x[i] == "T": t += 1 if s > 0: s -= 1 t -= 1 else: s += 1 print(s + t)
[ 7, 0, 13, 4, 13, 0, 13, 39, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 0, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 14, 40, 18, 13, 13, 18, 13, 2, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 0, 13, 39, 17, 17, 0, 13, 18, 13, 17, 28, 13, 4, 13, 17, 2, 4, 13, 13, 17, 17, 14, 2, 18, 13, 13, 18, 13, 2, 13, 17, 0, 13, 2, 18, 13, 2, 13, 17, 18, 13, 13, 0, 18, 13, 2, 13, 17, 18, 13, 13, 0, 18, 13, 2, 13, 17, 2, 18, 13, 13, 18, 13, 2, 13, 17, 0, 18, 13, 2, 13, 17, 17, 0, 13, 2, 18, 13, 17, 18, 13, 17, 4, 13, 13, 10, 2, 13, 10, 17, 13, 10, 2, 13, 10, 39, 13, 10, 39, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 18, 13 ]
[ [ 171, 2 ], [ 165, 6 ], [ 172, 11 ], [ 166, 16 ], [ 156, 20 ], [ 24, 23 ], [ 172, 29 ], [ 172, 33 ], [ 23, 34 ], [ 172, 36 ], [ 23, 38 ], [ 166, 42 ], [ 157, 44 ], [ 169, 44 ], [ 175, 44 ], [ 174, 46 ], [ 168, 49 ], [ 166, 53 ], [ 169, 55 ], [ 175, 55 ], [ 157, 55 ], [ 172, 59 ], [ 166, 64 ], [ 162, 68 ], [ 177, 73 ], [ 163, 75 ], [ 166, 75 ], [ 79, 78 ], [ 163, 85 ], [ 166, 85 ], [ 163, 91 ], [ 166, 91 ], [ 78, 92 ], [ 163, 94 ], [ 166, 94 ], [ 78, 96 ], [ 159, 99 ], [ 163, 102 ], [ 166, 102 ], [ 78, 104 ], [ 163, 107 ], [ 166, 107 ], [ 78, 108 ], [ 115, 110 ], [ 163, 111 ], [ 166, 111 ], [ 78, 113 ], [ 163, 116 ], [ 166, 116 ], [ 78, 117 ], [ 124, 119 ], [ 163, 120 ], [ 166, 120 ], [ 78, 122 ], [ 163, 126 ], [ 166, 126 ], [ 78, 127 ], [ 163, 129 ], [ 166, 129 ], [ 78, 131 ], [ 139, 134 ], [ 163, 135 ], [ 166, 135 ], [ 78, 137 ], [ 153, 141 ], [ 163, 144 ], [ 166, 144 ], [ 163, 147 ], [ 166, 147 ], [ 154, 151 ], [ 160, 151 ], [ 178, 151 ], [ 153, 154 ], [ 156, 157 ], [ 159, 160 ], [ 162, 163 ], [ 165, 166 ], [ 168, 169 ], [ 171, 172 ], [ 174, 175 ], [ 177, 178 ] ]
[ "X = input()\nlis = []\nif X[0] == 'S':\n lis.append(0)\ncnt = 1\nfor i in range(1,len(X)):\n if X[i] != X[i-1]:\n lis.append(cnt)\n cnt = 0\n cnt += 1\nlis.append(cnt)\nif X[-1] == 'T':\n lis.append(0)\nelse:\n lis += [0,0]\n#print(lis)\nans = lis[0]\nfor i in range(1,len(lis)-2,2):\n if lis[i] < lis[i+1]:\n ans += lis[i+1]-lis[i]\n lis[i+1] -= lis[i]\n else:\n lis[i+2] += lis[i] - lis[i+1]\n lis[i+1] = 0\nans += (lis[-1] + lis[-2])\n#print(lis)\nprint(ans)", "X = input()", "X", "input()", "input", "lis = []", "lis", "[]", "if X[0] == 'S':\n lis.append(0)", "X[0] == 'S'", "X[0]", "X", "0", "'S'", "lis.append(0)", "lis.append", "lis", "append", "0", "cnt = 1", "cnt", "1", "for i in range(1,len(X)):\n if X[i] != X[i-1]:\n lis.append(cnt)\n cnt = 0\n cnt += 1", "i", "range(1,len(X))", "range", "1", "len(X)", "len", "X", "if X[i] != X[i-1]:\n lis.append(cnt)\n cnt = 0\n ", "X[i] != X[i-1]", "X[i]", "X", "i", "X[i-1]", "X", "i-1", "i", "1", "lis.append(cnt)", "lis.append", "lis", "append", "cnt", "cnt = 0", "cnt", "0", "cnt += 1", "cnt", "1", "lis.append(cnt)", "lis.append", "lis", "append", "cnt", "if X[-1] == 'T':\n lis.append(0)\nelse:\n lis += [0,0]\n#print(lis)", "X[-1] == 'T'", "X[-1]", "X", "-1", "'T'", "lis.append(0)", "lis.append", "lis", "append", "0", "lis += [0,0]", "lis", "[0,0]", "0", "0", "ans = lis[0]", "ans", "lis[0]", "lis", "0", "for i in range(1,len(lis)-2,2):\n if lis[i] < lis[i+1]:\n ans += lis[i+1]-lis[i]\n lis[i+1] -= lis[i]\n else:\n lis[i+2] += lis[i] - lis[i+1]\n lis[i+1] = 0", "i", "range(1,len(lis)-2,2)", "range", "1", "len(lis)-2", "len(lis)", "len", "lis", "2", "2", "if lis[i] < lis[i+1]:\n ans += lis[i+1]-lis[i]\n lis[i+1] -= lis[i]\n else:\n lis[i+2] += lis[i] - lis[i+1]\n lis[i+1] = 0", "lis[i] < lis[i+1]", "lis[i]", "lis", "i", "lis[i+1]", "lis", "i+1", "i", "1", "ans += lis[i+1]-lis[i]", "ans", "lis[i+1]-lis[i]", "lis[i+1]", "lis", "i+1", "i", "1", "lis[i]", "lis", "i", "lis[i+1] -= lis[i]", "lis[i+1]", "lis", "i+1", "i", "1", "lis[i]", "lis", "i", "lis[i+2] += lis[i] - lis[i+1]", "lis[i+2]", "lis", "i+2", "i", "2", "lis[i] - lis[i+1]", "lis[i]", "lis", "i", "lis[i+1]", "lis", "i+1", "i", "1", "lis[i+1] = 0", "lis[i+1]", "lis", "i+1", "i", "1", "0", "ans += (lis[-1] + lis[-2])", "ans", "lis[-1] + lis[-2]", "lis[-1]", "lis", "-1", "lis[-2]", "lis", "-2", "print(ans)", "print", "ans", "ans += (lis[-1] + lis[-2])", "lis[-1] + lis[-2]", "ans", "cnt = 1", "1", "cnt", "ans += lis[i+1]-lis[i]", "lis[i+1]-lis[i]", "ans", "lis += [0,0]", "[0,0]", "lis", "lis = []", "[]", "lis", "cnt += 1", "1", "cnt", "X = input()", "input()", "X", "cnt = 0", "0", "cnt", "ans = lis[0]", "lis[0]", "ans" ]
X = input() lis = [] if X[0] == 'S': lis.append(0) cnt = 1 for i in range(1,len(X)): if X[i] != X[i-1]: lis.append(cnt) cnt = 0 cnt += 1 lis.append(cnt) if X[-1] == 'T': lis.append(0) else: lis += [0,0] #print(lis) ans = lis[0] for i in range(1,len(lis)-2,2): if lis[i] < lis[i+1]: ans += lis[i+1]-lis[i] lis[i+1] -= lis[i] else: lis[i+2] += lis[i] - lis[i+1] lis[i+1] = 0 ans += (lis[-1] + lis[-2]) #print(lis) print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 2, 13, 13, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 47, 2 ], [ 53, 6 ], [ 62, 9 ], [ 56, 12 ], [ 16, 15 ], [ 48, 20 ], [ 48, 24 ], [ 15, 25 ], [ 50, 28 ], [ 59, 31 ], [ 65, 34 ], [ 57, 37 ], [ 66, 37 ], [ 60, 39 ], [ 63, 39 ], [ 51, 40 ], [ 54, 40 ], [ 66, 44 ], [ 57, 44 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "X = input()\n\ns_cnt = 0\nt_cnt = 0\n\nans = 0\n\nfor n in range(len(X)):\n if X[n] == \"S\":\n s_cnt += 1\n else:\n t_cnt += 1\n ans = max(ans,t_cnt-s_cnt)\nprint(ans*2)", "X = input()", "X", "input()", "input", "s_cnt = 0", "s_cnt", "0", "t_cnt = 0", "t_cnt", "0", "ans = 0", "ans", "0", "for n in range(len(X)):\n if X[n] == \"S\":\n s_cnt += 1\n else:\n t_cnt += 1\n ans = max(ans,t_cnt-s_cnt)", "n", "range(len(X))", "range", "len(X)", "len", "X", "if X[n] == \"S\":\n s_cnt += 1\n else:\n t_cnt += 1\n ", "X[n] == \"S\"", "X[n]", "X", "n", "\"S\"", "s_cnt += 1", "s_cnt", "1", "t_cnt += 1", "t_cnt", "1", "ans = max(ans,t_cnt-s_cnt)", "ans", "max(ans,t_cnt-s_cnt)", "max", "ans", "t_cnt-s_cnt", "t_cnt", "s_cnt", "print(ans*2)", "print", "ans*2", "ans", "2", "X = input()", "input()", "X", "s_cnt += 1", "1", "s_cnt", "s_cnt = 0", "0", "s_cnt", "ans = 0", "0", "ans", "t_cnt += 1", "1", "t_cnt", "t_cnt = 0", "0", "t_cnt", "ans = max(ans,t_cnt-s_cnt)", "max(ans,t_cnt-s_cnt)", "ans" ]
X = input() s_cnt = 0 t_cnt = 0 ans = 0 for n in range(len(X)): if X[n] == "S": s_cnt += 1 else: t_cnt += 1 ans = max(ans,t_cnt-s_cnt) print(ans*2)
[ 7, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 43, 2 ], [ 43, 5 ], [ 9, 8 ], [ 8, 13 ], [ 37, 16 ], [ 41, 20 ], [ 35, 20 ], [ 38, 20 ], [ 46, 23 ], [ 34, 26 ], [ 35, 31 ], [ 38, 31 ], [ 41, 31 ], [ 47, 32 ], [ 44, 32 ], [ 34, 35 ], [ 37, 38 ], [ 43, 41 ], [ 43, 44 ], [ 46, 47 ] ]
[ "a = b = 0\nfor s in input():\n if s == 'S':\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1\nprint(a+b)", "a = b = 0", "a", "0", "= b = 0", "b", "0", "for s in input():\n if s == 'S':\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1", "s", "input()", "input", "if s == 'S':\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1", "s == 'S'", "s", "'S'", "a += 1", "a", "1", "if a == 0:\n b += 1\n else:\n a -= 1", "a == 0", "a", "0", "b += 1", "b", "1", "a -= 1", "a", "1", "print(a+b)", "print", "a+b", "a", "b", "a -= 1", "1", "a", "a += 1", "1", "a", "a = b = 0", "0", "a", "b = 0", "0", "b", "b += 1", "1", "b" ]
a = b = 0 for s in input(): if s == 'S': a += 1 else: if a == 0: b += 1 else: a -= 1 print(a+b)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 13, 14, 13, 0, 13, 4, 18, 13, 13, 14, 2, 2, 13, 17, 2, 13, 17, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 56, 3 ], [ 53, 7 ], [ 12, 11 ], [ 54, 11 ], [ 50, 16 ], [ 57, 19 ], [ 51, 24 ], [ 11, 27 ], [ 57, 31 ], [ 51, 33 ], [ 57, 36 ], [ 11, 38 ], [ 57, 41 ], [ 11, 43 ], [ 57, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "from collections import deque\nd = deque()\nX = input()\nfor c in X:\n if d:\n last = d.pop()\n if last == \"S\" and c == \"T\":\n pass\n else:\n d.append(last)\n d.append(c)\n else:\n d.append(c)\nprint(len(d))", "from collections import deque", "d = deque()", "d", "deque()", "deque", "X = input()", "X", "input()", "input", "for c in X:\n if d:\n last = d.pop()\n if last == \"S\" and c == \"T\":\n pass\n else:\n d.append(last)\n d.append(c)\n else:\n d.append(c)", "c", "X", "if d:\n last = d.pop()\n if last == \"S\" and c == \"T\":\n pass\n else:\n d.append(last)\n d.append(c)\n else:\n d.append(c)", "d", "last = d.pop()", "last", "d.pop()", "d.pop", "d", "pop", "if last == \"S\" and c == \"T\":\n pass\n else:\n d.append(last)\n d.append(c)\n ", "last == \"S\" and c == \"T\"", "last == \"S\"", "last", "\"S\"", "c == \"T\"", "c", "\"T\"", "d.append(last)", "d.append", "d", "append", "last", "d.append(c)", "d.append", "d", "append", "c", "d.append(c)", "d.append", "d", "append", "c", "print(len(d))", "print", "len(d)", "len", "d", "last = d.pop()", "d.pop()", "last", "X = input()", "input()", "X", "d = deque()", "deque()", "d" ]
from collections import deque d = deque() X = input() for c in X: if d: last = d.pop() if last == "S" and c == "T": pass else: d.append(last) d.append(c) else: d.append(c) print(len(d))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 14, 40, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 73, 2 ], [ 64, 8 ], [ 74, 11 ], [ 52, 13 ], [ 67, 16 ], [ 70, 19 ], [ 23, 22 ], [ 74, 22 ], [ 22, 26 ], [ 58, 29 ], [ 76, 32 ], [ 68, 36 ], [ 56, 36 ], [ 59, 36 ], [ 55, 39 ], [ 61, 42 ], [ 65, 47 ], [ 62, 50 ], [ 71, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "x = list(input())\nn = len(x)\nct = 0\ncs = 0\nc = 0\nfor X in x:\n if X == \"S\":\n cs += 1\n else:\n ct += 1\n if cs >= 1:\n cs -= 1\n c += 1\nprint(n-2*c)", "x = list(input())", "x", "list(input())", "list", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "ct = 0", "ct", "0", "cs = 0", "cs", "0", "c = 0", "c", "0", "for X in x:\n if X == \"S\":\n cs += 1\n else:\n ct += 1\n if cs >= 1:\n cs -= 1\n c += 1", "X", "x", "if X == \"S\":\n cs += 1\n else:\n ct += 1\n if cs >= 1:\n cs -= 1\n c += 1", "X == \"S\"", "X", "\"S\"", "cs += 1", "cs", "1", "ct += 1", "ct", "1", "if cs >= 1:\n cs -= 1\n c += 1", "cs >= 1", "cs", "1", "cs -= 1", "cs", "1", "c += 1", "c", "1", "print(n-2*c)", "print", "n-2*c", "n", "2*c", "2", "c", "ct = 0", "0", "ct", "cs -= 1", "1", "cs", "cs += 1", "1", "cs", "c += 1", "1", "c", "n = len(x)", "len(x)", "n", "cs = 0", "0", "cs", "c = 0", "0", "c", "x = list(input())", "list(input())", "x", "ct += 1", "1", "ct" ]
x = list(input()) n = len(x) ct = 0 cs = 0 c = 0 for X in x: if X == "S": cs += 1 else: ct += 1 if cs >= 1: cs -= 1 c += 1 print(n-2*c)
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 12, 13, 29, 4, 18, 4, 18, 18, 13, 13, 13, 13, 12, 13, 0, 13, 4, 13, 0, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 4, 18, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 25, 24 ], [ 87, 26 ], [ 29, 28 ], [ 35, 34 ], [ 38, 37 ], [ 41, 40 ], [ 24, 40 ], [ 40, 44 ], [ 28, 48 ], [ 40, 50 ], [ 53, 52 ], [ 40, 57 ], [ 34, 60 ], [ 69, 60 ], [ 52, 60 ], [ 64, 63 ], [ 28, 66 ], [ 70, 69 ], [ 73, 72 ], [ 72, 77 ], [ 37, 77 ], [ 69, 78 ], [ 52, 78 ], [ 34, 78 ], [ 90, 84 ] ]
[ "import sys\nimport math # noqa\nimport bisect # noqa\nimport queue # noqa\n\n\ndef input():\n return sys.stdin.readline().rstrip()\n\n\ndef main():\n X = input()\n\n que = queue.LifoQueue()\n cnt = 0\n rest_T = 0\n for x in X:\n if x == 'S':\n que.put(x)\n cnt += 1\n elif x == 'T' and cnt > 0:\n _ = que.get()\n cnt -= 1\n else:\n rest_T += 1\n\n print(rest_T + cnt)\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "import math", "math", "import bisect", "bisect", "import queue", "queue", "def input():\n return sys.stdin.readline().rstrip()", "input", "return sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "def main():\n X = input()\n\n que = queue.LifoQueue()\n cnt = 0\n rest_T = 0\n for x in X:\n if x == 'S':\n que.put(x)\n cnt += 1\n elif x == 'T' and cnt > 0:\n _ = que.get()\n cnt -= 1\n else:\n rest_T += 1\n\n print(rest_T + cnt)", "main", "X = input()", "X", "input()", "input", "que = queue.LifoQueue()", "que", "queue.LifoQueue()", "queue.LifoQueue", "queue", "LifoQueue", "cnt = 0", "cnt", "0", "rest_T = 0", "rest_T", "0", "for x in X:\n if x == 'S':\n que.put(x)\n cnt += 1\n elif x == 'T' and cnt > 0:\n _ = que.get()\n cnt -= 1\n else:\n rest_T += 1\n\n ", "x", "X", "if x == 'S':\n que.put(x)\n cnt += 1\n elif x == 'T' and cnt > 0:\n _ = que.get()\n cnt -= 1\n else:\n rest_T += 1\n\n ", "x == 'S'", "x", "'S'", "que.put(x)", "que.put", "que", "put", "x", "cnt += 1", "cnt", "1", "elif x == 'T' and cnt > 0:\n _ = que.get()\n cnt -= 1\n ", "x == 'T' and cnt > 0", "x == 'T'", "x", "'T'", "cnt > 0", "cnt", "0", "_ = que.get()", "_", "que.get()", "que.get", "que", "get", "cnt -= 1", "cnt", "1", "rest_T += 1", "rest_T", "1", "print(rest_T + cnt)", "print", "rest_T + cnt", "rest_T", "cnt", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def input():\n return sys.stdin.readline().rstrip()", "def input():\n return sys.stdin.readline().rstrip()", "input", "def main():\n X = input()\n\n que = queue.LifoQueue()\n cnt = 0\n rest_T = 0\n for x in X:\n if x == 'S':\n que.put(x)\n cnt += 1\n elif x == 'T' and cnt > 0:\n _ = que.get()\n cnt -= 1\n else:\n rest_T += 1\n\n print(rest_T + cnt)", "def main():\n X = input()\n\n que = queue.LifoQueue()\n cnt = 0\n rest_T = 0\n for x in X:\n if x == 'S':\n que.put(x)\n cnt += 1\n elif x == 'T' and cnt > 0:\n _ = que.get()\n cnt -= 1\n else:\n rest_T += 1\n\n print(rest_T + cnt)", "main" ]
import sys import math # noqa import bisect # noqa import queue # noqa def input(): return sys.stdin.readline().rstrip() def main(): X = input() que = queue.LifoQueue() cnt = 0 rest_T = 0 for x in X: if x == 'S': que.put(x) cnt += 1 elif x == 'T' and cnt > 0: _ = que.get() cnt -= 1 else: rest_T += 1 print(rest_T + cnt) if __name__ == '__main__': main()
[ 7, 15, 13, 0, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 40, 13, 0, 13, 17, 0, 13, 17, 0, 13, 13, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 67, 4 ], [ 55, 15 ], [ 58, 18 ], [ 61, 21 ], [ 25, 24 ], [ 68, 24 ], [ 24, 28 ], [ 52, 31 ], [ 56, 35 ], [ 50, 35 ], [ 53, 35 ], [ 64, 37 ], [ 49, 40 ], [ 70, 43 ], [ 50, 44 ], [ 53, 44 ], [ 56, 44 ], [ 71, 47 ], [ 65, 47 ], [ 62, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 50, 70 ], [ 53, 70 ], [ 56, 70 ], [ 70, 71 ] ]
[ "import sys\nX = sys.stdin.readline().rstrip()\nS = 0\nT = 0\nans = 0\nfor x in X:\n if x == \"S\":\n S += 1\n else:\n if not S:\n ans += 1\n else:\n S -= 1\nans += S\nprint(ans)", "import sys", "sys", "X = sys.stdin.readline().rstrip()", "X", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "S = 0", "S", "0", "T = 0", "T", "0", "ans = 0", "ans", "0", "for x in X:\n if x == \"S\":\n S += 1\n else:\n if not S:\n ans += 1\n else:\n S -= 1", "x", "X", "if x == \"S\":\n S += 1\n else:\n if not S:\n ans += 1\n else:\n S -= 1", "x == \"S\"", "x", "\"S\"", "S += 1", "S", "1", "if not S:\n ans += 1\n else:\n S -= 1", "not S", "S", "ans += 1", "ans", "1", "S -= 1", "S", "1", "ans += S", "ans", "S", "print(ans)", "print", "ans", "S -= 1", "1", "S", "S += 1", "1", "S", "S = 0", "0", "S", "T = 0", "0", "T", "ans = 0", "0", "ans", "ans += 1", "1", "ans", "X = sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "X", "ans += S", "S", "ans" ]
import sys X = sys.stdin.readline().rstrip() S = 0 T = 0 ans = 0 for x in X: if x == "S": S += 1 else: if not S: ans += 1 else: S -= 1 ans += S print(ans)
[ 7, 0, 13, 4, 13, 12, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 29, 2, 13, 13, 23, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 12, 13 ]
[ [ 45, 2 ], [ 9, 8 ], [ 12, 11 ], [ 15, 14 ], [ 38, 14 ], [ 14, 18 ], [ 22, 21 ], [ 8, 25 ], [ 28, 25 ], [ 21, 25 ], [ 29, 28 ], [ 32, 31 ], [ 28, 35 ], [ 21, 35 ], [ 8, 35 ], [ 31, 36 ], [ 11, 36 ], [ 38, 38 ], [ 49, 42 ], [ 46, 43 ], [ 45, 46 ] ]
[ "X = input()\ndef solve(X):\n ns = 0\n nt = 0\n for x in X:\n if x == 'S':\n ns += 1\n elif ns>0:\n ns -= 1\n else:\n nt += 1\n return ns+nt\nprint(solve(X))", "X = input()", "X", "input()", "input", "def solve(X):\n ns = 0\n nt = 0\n for x in X:\n if x == 'S':\n ns += 1\n elif ns>0:\n ns -= 1\n else:\n nt += 1\n return ns+nt", "solve", "ns = 0", "ns", "0", "nt = 0", "nt", "0", "for x in X:\n if x == 'S':\n ns += 1\n elif ns>0:\n ns -= 1\n else:\n nt += 1\n ", "x", "X", "if x == 'S':\n ns += 1\n elif ns>0:\n ns -= 1\n else:\n nt += 1\n ", "x == 'S'", "x", "'S'", "ns += 1", "ns", "1", "elif ns>0:\n ns -= 1\n ", "ns>0", "ns", "0", "ns -= 1", "ns", "1", "nt += 1", "nt", "1", "return ns+nt", "ns+nt", "ns", "nt", "X", "X", "print(solve(X))", "print", "solve(X)", "solve", "X", "X = input()", "input()", "X", "def solve(X):\n ns = 0\n nt = 0\n for x in X:\n if x == 'S':\n ns += 1\n elif ns>0:\n ns -= 1\n else:\n nt += 1\n return ns+nt", "def solve(X):\n ns = 0\n nt = 0\n for x in X:\n if x == 'S':\n ns += 1\n elif ns>0:\n ns -= 1\n else:\n nt += 1\n return ns+nt", "solve" ]
X = input() def solve(X): ns = 0 nt = 0 for x in X: if x == 'S': ns += 1 elif ns>0: ns -= 1 else: nt += 1 return ns+nt print(solve(X))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 58, 2 ], [ 70, 6 ], [ 59, 9 ], [ 55, 11 ], [ 52, 14 ], [ 18, 17 ], [ 71, 20 ], [ 59, 24 ], [ 17, 25 ], [ 64, 28 ], [ 59, 33 ], [ 17, 34 ], [ 65, 38 ], [ 53, 38 ], [ 62, 38 ], [ 61, 41 ], [ 67, 44 ], [ 68, 49 ], [ 56, 49 ], [ 62, 50 ], [ 65, 50 ], [ 53, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "X = input()\nn = len(X)\ncnt = 0\nS_check = 0\n\nfor i in range(n):\n if X[i] == 'S':\n S_check += 1\n\n if X[i] == 'T':\n if S_check > 0:\n S_check -= 1\n else:\n cnt += 1\n\nprint(cnt + S_check)", "X = input()", "X", "input()", "input", "n = len(X)", "n", "len(X)", "len", "X", "cnt = 0", "cnt", "0", "S_check = 0", "S_check", "0", "for i in range(n):\n if X[i] == 'S':\n S_check += 1\n\n if X[i] == 'T':\n if S_check > 0:\n S_check -= 1\n else:\n cnt += 1", "i", "range(n)", "range", "n", "if X[i] == 'S':\n S_check += 1\n\n ", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "S_check += 1", "S_check", "1", "if X[i] == 'T':\n if S_check > 0:\n S_check -= 1\n else:\n cnt += 1", "X[i] == 'T'", "X[i]", "X", "i", "'T'", "if S_check > 0:\n S_check -= 1\n else:\n cnt += 1", "S_check > 0", "S_check", "0", "S_check -= 1", "S_check", "1", "cnt += 1", "cnt", "1", "print(cnt + S_check)", "print", "cnt + S_check", "cnt", "S_check", "S_check = 0", "0", "S_check", "cnt = 0", "0", "cnt", "X = input()", "input()", "X", "S_check -= 1", "1", "S_check", "S_check += 1", "1", "S_check", "cnt += 1", "1", "cnt", "n = len(X)", "len(X)", "n" ]
X = input() n = len(X) cnt = 0 S_check = 0 for i in range(n): if X[i] == 'S': S_check += 1 if X[i] == 'T': if S_check > 0: S_check -= 1 else: cnt += 1 print(cnt + S_check)
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 42, 2, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 2, 18, 13, 13, 17, 40, 13, 17, 42, 2, 2, 13, 4, 13, 13, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 2, 4, 13, 13, 13, 17, 0, 13, 4, 13, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 14, 2, 13, 17, 4, 13, 10, 4, 13, 10, 2, 13, 10, 12, 13 ]
[ [ 120, 11 ], [ 123, 16 ], [ 26, 25 ], [ 30, 29 ], [ 33, 32 ], [ 36, 35 ], [ 39, 38 ], [ 38, 42 ], [ 104, 42 ], [ 84, 42 ], [ 56, 42 ], [ 25, 45 ], [ 25, 49 ], [ 38, 50 ], [ 104, 50 ], [ 84, 50 ], [ 56, 50 ], [ 54, 53 ], [ 57, 56 ], [ 25, 62 ], [ 38, 63 ], [ 104, 63 ], [ 84, 63 ], [ 56, 63 ], [ 29, 66 ], [ 95, 66 ], [ 53, 66 ], [ 38, 71 ], [ 84, 71 ], [ 104, 71 ], [ 56, 71 ], [ 25, 74 ], [ 25, 77 ], [ 38, 78 ], [ 84, 78 ], [ 104, 78 ], [ 56, 78 ], [ 82, 81 ], [ 85, 84 ], [ 88, 87 ], [ 53, 91 ], [ 29, 91 ], [ 95, 91 ], [ 81, 92 ], [ 32, 92 ], [ 101, 92 ], [ 96, 95 ], [ 53, 98 ], [ 29, 98 ], [ 95, 98 ], [ 81, 99 ], [ 32, 99 ], [ 101, 99 ], [ 102, 101 ], [ 105, 104 ], [ 25, 111 ], [ 87, 112 ], [ 35, 112 ], [ 127, 118 ], [ 120, 121 ], [ 123, 124 ] ]
[ "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n x = input()\n\n cnt_S = 0\n cnt_T = 0\n res = 0\n i = 0\n while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n print(len(x) - res)\n\n\nif __name__ == '__main__':\n resolve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "f_inf = float('inf')", "f_inf", "float('inf')", "float", "'inf'", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "def resolve():\n x = input()\n\n cnt_S = 0\n cnt_T = 0\n res = 0\n i = 0\n while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n print(len(x) - res)", "resolve", "x = input()", "x", "input()", "input", "cnt_S = 0", "cnt_S", "0", "cnt_T = 0", "cnt_T", "0", "res = 0", "res", "0", "i = 0", "i", "0", "while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n ", "i < len(x)", "i", "len(x)", "len", "x", "if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n ", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "cnt_S += 1", "cnt_S", "1", "i += 1", "i", "1", "elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n ", "x[i] == \"T\" and cnt_S != 0", "x[i] == \"T\"", "x[i]", "x", "i", "\"T\"", "cnt_S != 0", "cnt_S", "0", "while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n ", "i < len(x) and x[i] == \"T\"", "i < len(x)", "i", "len(x)", "len", "x", "x[i] == \"T\"", "x[i]", "x", "i", "\"T\"", "cnt_T += 1", "cnt_T", "1", "i += 1", "i", "1", "res += min(cnt_S, cnt_T) * 2", "res", "min(cnt_S, cnt_T) * 2", "min(cnt_S, cnt_T)", "min", "cnt_S", "cnt_T", "2", "cnt_S -= min(cnt_S, cnt_T)", "cnt_S", "min(cnt_S, cnt_T)", "min", "cnt_S", "cnt_T", "cnt_T = 0", "cnt_T", "0", "i += 1", "i", "1", "print(len(x) - res)", "print", "len(x) - res", "len(x)", "len", "x", "res", "if __name__ == '__main__':\n resolve()", "__name__ == '__main__'", "__name__", "'__main__'", "resolve()", "resolve", "f_inf = float('inf')", "float('inf')", "f_inf", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "def resolve():\n x = input()\n\n cnt_S = 0\n cnt_T = 0\n res = 0\n i = 0\n while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n print(len(x) - res)", "def resolve():\n x = input()\n\n cnt_S = 0\n cnt_T = 0\n res = 0\n i = 0\n while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n print(len(x) - res)", "resolve" ]
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): x = input() cnt_S = 0 cnt_T = 0 res = 0 i = 0 while i < len(x): if x[i] == "S": cnt_S += 1 i += 1 elif x[i] == "T" and cnt_S != 0: while i < len(x) and x[i] == "T": cnt_T += 1 i += 1 res += min(cnt_S, cnt_T) * 2 cnt_S -= min(cnt_S, cnt_T) cnt_T = 0 else: i += 1 print(len(x) - res) if __name__ == '__main__': resolve()
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 4, 18, 13, 13, 17, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 12, 4, 13, 4, 18, 18, 13, 13, 13, 0, 13, 12, 4, 13, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 40, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 129, 29 ], [ 138, 34 ], [ 132, 41 ], [ 144, 52 ], [ 141, 67 ], [ 87, 86 ], [ 93, 92 ], [ 96, 95 ], [ 86, 98 ], [ 101, 100 ], [ 86, 100 ], [ 100, 104 ], [ 108, 107 ], [ 92, 111 ], [ 114, 111 ], [ 107, 111 ], [ 115, 114 ], [ 118, 117 ], [ 117, 121 ], [ 95, 121 ], [ 136, 127 ], [ 129, 130 ], [ 132, 133 ], [ 138, 139 ], [ 141, 142 ], [ 144, 145 ] ]
[ "import sys\n\n# import re\nimport math\nimport collections\n# import decimal\nimport bisect\nimport itertools\nimport fractions\n# import functools\nimport copy\nimport heapq\nimport decimal\n# import statistics\nimport queue\nimport numpy as np\n\nsys.setrecursionlimit(10000001)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\n\ndef main():\n x = list(input())\n s_cnt = 0\n\n ans = len(x)\n for xi in x:\n if xi == \"S\":\n s_cnt += 1\n else:\n if s_cnt != 0:\n s_cnt -= 1\n ans -= 2\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "import math", "math", "import collections", "collections", "import bisect", "bisect", "import itertools", "itertools", "import fractions", "fractions", "import copy", "copy", "import heapq", "heapq", "import decimal", "decimal", "import queue", "queue", "import numpy as np", "numpy", "sys.setrecursionlimit(10000001)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10000001", "INF = 10 ** 16", "INF", "10 ** 16", "10", "16", "MOD = 10 ** 9 + 7", "MOD", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "ni = lambda: int(sys.stdin.readline())", "ni", "lambda: int(sys.stdin.readline())", "int(sys.stdin.readline())", "int", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "ns = lambda: map(int, sys.stdin.readline().split())", "ns", "lambda: map(int, sys.stdin.readline().split())", "map(int, sys.stdin.readline().split())", "map", "int", "sys.stdin.readline().split()", "sys.stdin.readline().split", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "split", "na = lambda: list(map(int, sys.stdin.readline().split()))", "na", "lambda: list(map(int, sys.stdin.readline().split()))", "list(map(int, sys.stdin.readline().split()))", "list", "map(int, sys.stdin.readline().split())", "map", "int", "sys.stdin.readline().split()", "sys.stdin.readline().split", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "split", "def main():\n x = list(input())\n s_cnt = 0\n\n ans = len(x)\n for xi in x:\n if xi == \"S\":\n s_cnt += 1\n else:\n if s_cnt != 0:\n s_cnt -= 1\n ans -= 2\n\n print(ans)", "main", "x = list(input())", "x", "list(input())", "list", "input()", "input", "s_cnt = 0", "s_cnt", "0", "ans = len(x)", "ans", "len(x)", "len", "x", "for xi in x:\n if xi == \"S\":\n s_cnt += 1\n else:\n if s_cnt != 0:\n s_cnt -= 1\n ans -= 2\n\n ", "xi", "x", "if xi == \"S\":\n s_cnt += 1\n else:\n if s_cnt != 0:\n s_cnt -= 1\n ans -= 2\n\n ", "xi == \"S\"", "xi", "\"S\"", "s_cnt += 1", "s_cnt", "1", "if s_cnt != 0:\n s_cnt -= 1\n ans -= 2\n\n ", "s_cnt != 0", "s_cnt", "0", "s_cnt -= 1", "s_cnt", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "INF = 10 ** 16", "10 ** 16", "INF", "ni = lambda: int(sys.stdin.readline())", "lambda: int(sys.stdin.readline())", "ni", "def main():\n x = list(input())\n s_cnt = 0\n\n ans = len(x)\n for xi in x:\n if xi == \"S\":\n s_cnt += 1\n else:\n if s_cnt != 0:\n s_cnt -= 1\n ans -= 2\n\n print(ans)", "def main():\n x = list(input())\n s_cnt = 0\n\n ans = len(x)\n for xi in x:\n if xi == \"S\":\n s_cnt += 1\n else:\n if s_cnt != 0:\n s_cnt -= 1\n ans -= 2\n\n print(ans)", "main", "MOD = 10 ** 9 + 7", "10 ** 9 + 7", "MOD", "na = lambda: list(map(int, sys.stdin.readline().split()))", "lambda: list(map(int, sys.stdin.readline().split()))", "na", "ns = lambda: map(int, sys.stdin.readline().split())", "lambda: map(int, sys.stdin.readline().split())", "ns" ]
import sys # import re import math import collections # import decimal import bisect import itertools import fractions # import functools import copy import heapq import decimal # import statistics import queue import numpy as np sys.setrecursionlimit(10000001) INF = 10 ** 16 MOD = 10 ** 9 + 7 ni = lambda: int(sys.stdin.readline()) ns = lambda: map(int, sys.stdin.readline().split()) na = lambda: list(map(int, sys.stdin.readline().split())) # ===CODE=== def main(): x = list(input()) s_cnt = 0 ans = len(x) for xi in x: if xi == "S": s_cnt += 1 else: if s_cnt != 0: s_cnt -= 1 ans -= 2 print(ans) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 18, 13, 39, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 18, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 71, 2 ], [ 62, 6 ], [ 59, 9 ], [ 65, 12 ], [ 72, 14 ], [ 19, 18 ], [ 66, 23 ], [ 72, 23 ], [ 66, 27 ], [ 72, 27 ], [ 18, 28 ], [ 53, 31 ], [ 60, 35 ], [ 69, 35 ], [ 54, 35 ], [ 56, 38 ], [ 68, 41 ], [ 66, 48 ], [ 72, 48 ], [ 57, 51 ], [ 63, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "x = input()\n\ncnt = 0\nnumt = 0\nx = x[::-1]\nfor i in range(len(x)):\n if x[i] == 'T':\n numt += 1\n else:\n if numt > 0:\n cnt += 1\n numt -= 1\nprint(len(x)-2*cnt)", "x = input()", "x", "input()", "input", "cnt = 0", "cnt", "0", "numt = 0", "numt", "0", "x = x[::-1]", "x", "x[::-1]", "x", "::-1", "-1", "for i in range(len(x)):\n if x[i] == 'T':\n numt += 1\n else:\n if numt > 0:\n cnt += 1\n numt -= 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == 'T':\n numt += 1\n else:\n if numt > 0:\n cnt += 1\n numt -= 1", "x[i] == 'T'", "x[i]", "x", "i", "'T'", "numt += 1", "numt", "1", "if numt > 0:\n cnt += 1\n numt -= 1", "numt > 0", "numt", "0", "cnt += 1", "cnt", "1", "numt -= 1", "numt", "1", "print(len(x)-2*cnt)", "print", "len(x)-2*cnt", "len(x)", "len", "x", "2*cnt", "2", "cnt", "numt += 1", "1", "numt", "cnt += 1", "1", "cnt", "numt = 0", "0", "numt", "cnt = 0", "0", "cnt", "x = x[::-1]", "x[::-1]", "x", "numt -= 1", "1", "numt", "x = input()", "input()", "x" ]
x = input() cnt = 0 numt = 0 x = x[::-1] for i in range(len(x)): if x[i] == 'T': numt += 1 else: if numt > 0: cnt += 1 numt -= 1 print(len(x)-2*cnt)
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 12, 13, 23, 13, 41, 28, 13, 4, 13, 13, 4, 2, 39, 13, 13, 12, 13, 23, 13, 23, 13, 23, 13, 41, 28, 13, 4, 13, 13, 4, 13, 12, 13, 23, 13, 23, 13, 23, 13, 23, 13, 0, 13, 4, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 2, 17, 13, 10, 4, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13 ]
[ [ 19, 18 ], [ 40, 40 ], [ 44, 43 ], [ 55, 55 ], [ 57, 57 ], [ 59, 59 ], [ 63, 62 ], [ 71, 71 ], [ 73, 73 ], [ 75, 75 ], [ 77, 77 ], [ 113, 79 ], [ 137, 84 ], [ 88, 87 ], [ 114, 87 ], [ 87, 91 ], [ 128, 94 ], [ 87, 99 ], [ 138, 102 ], [ 117, 102 ], [ 129, 102 ], [ 116, 105 ], [ 117, 111 ], [ 129, 111 ], [ 138, 111 ], [ 113, 114 ], [ 116, 117 ], [ 128, 129 ], [ 137, 138 ] ]
[ "import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for _ in range(j)]\ndef dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))\n\nS = input()\n'''\nf_cnt = b_cnt = 0\nfor m in S:\n if m != 'T':\n break\n f_cnt += 1\n\nfor m in S[::-1]:\n if m != 'S':\n break\n b_cnt += 1\nprint(max(f_cnt, b_cnt) * 2)\n'''\ns_cnt = 0\nfor m in S:\n if m == 'S':\n s_cnt += 1\n elif m == 'T' and s_cnt > 0:\n s_cnt -= 1\n\nprint(2*s_cnt)", "import sys", "sys", "sys.setrecursionlimit(10**8)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**8", "10", "8", "def ii(): return int(sys.stdin.readline())", "ii", "def mi(): return map(int, sys.stdin.readline().split())", "mi", "def li(): return list(map(int, sys.stdin.readline().split()))", "li", "list(map(int, sys.stdin.readline().split())) for _ in range(N)", "for _ in range(N)", "_", "range(N)", "range", "N", "for _ in range(N)", "list(map(int, sys.stdin.readline().split()))", "list", "map(int, sys.stdin.readline().split())", "map", "int", "sys.stdin.readline().split()", "sys.stdin.readline().split", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "split", "def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]", "li2", "N", "N", "[ini]*i for _ in range(j)", "for _ in range(j)", "_", "range(j)", "range", "j", "for _ in range(j)", "[ini]*i", "[ini]", "ini", "i", "def dp2(ini, i, j): return [[ini]*i for _ in range(j)]", "dp2", "ini", "ini", "i", "i", "j", "j", "[[ini]*i for _ in range(j)] for _ in range(k)", "for _ in range(k)", "_", "range(k)", "range", "k", "for _ in range(k)", "[[ini]*i for _ in range(j)]", "def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))", "dp3", "ini", "ini", "i", "i", "j", "j", "k", "k", "S = input()", "S", "input()", "input", "'''\nf_cnt = b_cnt = 0\nfor m in S:\n if m != 'T':\n break\n f_cnt += 1\n\nfor m in S[::-1]:\n if m != 'S':\n break\n b_cnt += 1\nprint(max(f_cnt, b_cnt) * 2)\n'''", "s_cnt = 0", "s_cnt", "0", "for m in S:\n if m == 'S':\n s_cnt += 1\n elif m == 'T' and s_cnt > 0:\n s_cnt -= 1", "m", "S", "if m == 'S':\n s_cnt += 1\n elif m == 'T' and s_cnt > 0:\n s_cnt -= 1", "m == 'S'", "m", "'S'", "s_cnt += 1", "s_cnt", "1", "elif m == 'T' and s_cnt > 0:\n s_cnt -= 1", "m == 'T' and s_cnt > 0", "m == 'T'", "m", "'T'", "s_cnt > 0", "s_cnt", "0", "s_cnt -= 1", "s_cnt", "1", "print(2*s_cnt)", "print", "2*s_cnt", "2", "s_cnt", "S = input()", "input()", "S", "s_cnt -= 1", "1", "s_cnt", "def mi(): return map(int, sys.stdin.readline().split())", "def mi(): return map(int, sys.stdin.readline().split())", "mi", "def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))", "def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))", "dp3", "def ii(): return int(sys.stdin.readline())", "def ii(): return int(sys.stdin.readline())", "ii", "s_cnt += 1", "1", "s_cnt", "def li(): return list(map(int, sys.stdin.readline().split()))", "def li(): return list(map(int, sys.stdin.readline().split()))", "li", "def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]", "def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]", "li2", "s_cnt = 0", "0", "s_cnt", "def dp2(ini, i, j): return [[ini]*i for _ in range(j)]", "def dp2(ini, i, j): return [[ini]*i for _ in range(j)]", "dp2" ]
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return map(int, sys.stdin.readline().split()) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): return [[ini]*i for _ in range(j)] def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)] #import bisect #bisect.bisect_left(B, a) #from collections import defaultdict #d = defaultdict(int) d[key] += value #from itertools import accumulate #list(accumulate(A)) S = input() ''' f_cnt = b_cnt = 0 for m in S: if m != 'T': break f_cnt += 1 for m in S[::-1]: if m != 'S': break b_cnt += 1 print(max(f_cnt, b_cnt) * 2) ''' s_cnt = 0 for m in S: if m == 'S': s_cnt += 1 elif m == 'T' and s_cnt > 0: s_cnt -= 1 print(2*s_cnt)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 55, 2 ], [ 61, 6 ], [ 56, 9 ], [ 58, 11 ], [ 64, 14 ], [ 18, 17 ], [ 62, 20 ], [ 56, 24 ], [ 17, 25 ], [ 70, 28 ], [ 56, 34 ], [ 17, 35 ], [ 59, 38 ], [ 68, 38 ], [ 71, 38 ], [ 52, 41 ], [ 67, 44 ], [ 62, 49 ], [ 53, 50 ], [ 65, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "x = input() #sys.stdin.readlineは最後が改行\nn = len(x)\n\ntama = 0\ncnt = 0\nfor i in range(n):\n if x[i] =='S':\n tama+=1\n elif x[i] =='T' and tama>0:\n cnt += 2\n tama-=1\nprint(n-cnt)", "x = input()", "x", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "tama = 0", "tama", "0", "cnt = 0", "cnt", "0", "for i in range(n):\n if x[i] =='S':\n tama+=1\n elif x[i] =='T' and tama>0:\n cnt += 2\n tama-=1", "i", "range(n)", "range", "n", "if x[i] =='S':\n tama+=1\n elif x[i] =='T' and tama>0:\n cnt += 2\n tama-=1", "x[i] =='S'", "x[i]", "x", "i", "'S'", "tama+=1", "tama", "1", "elif x[i] =='T' and tama>0:\n cnt += 2\n tama-=1", "x[i] =='T' and tama>0", "x[i] =='T'", "x[i]", "x", "i", "'T'", "tama>0", "tama", "0", "cnt += 2", "cnt", "2", "tama-=1", "tama", "1", "print(n-cnt)", "print", "n-cnt", "n", "cnt", "cnt += 2", "2", "cnt", "x = input()", "input()", "x", "tama = 0", "0", "tama", "n = len(x)", "len(x)", "n", "cnt = 0", "0", "cnt", "tama-=1", "1", "tama", "tama+=1", "1", "tama" ]
x = input() #sys.stdin.readlineは最後が改行 n = len(x) tama = 0 cnt = 0 for i in range(n): if x[i] =='S': tama+=1 elif x[i] =='T' and tama>0: cnt += 2 tama-=1 print(n-cnt)
[ 7, 14, 2, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 39, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 17, 14, 40, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 57, 6 ], [ 60, 12 ], [ 51, 15 ], [ 19, 18 ], [ 58, 18 ], [ 18, 22 ], [ 61, 26 ], [ 61, 33 ], [ 54, 36 ], [ 61, 39 ], [ 58, 46 ], [ 55, 48 ], [ 52, 48 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "if __name__ == '__main__':\n x = list(input())\n sl = []\n ans = 0\n for i in x:\n if i == \"S\":\n sl.append(1)\n else:\n if len(sl) != 0:\n ans += sl.pop()\n\n print(len(x) - ans * 2)", "if __name__ == '__main__':\n x = list(input())\n sl = []\n ans = 0\n for i in x:\n if i == \"S\":\n sl.append(1)\n else:\n if len(sl) != 0:\n ans += sl.pop()\n\n print(len(x) - ans * 2)", "__name__ == '__main__'", "__name__", "'__main__'", "x = list(input())", "x", "list(input())", "list", "input()", "input", "sl = []", "sl", "[]", "ans = 0", "ans", "0", "for i in x:\n if i == \"S\":\n sl.append(1)\n else:\n if len(sl) != 0:\n ans += sl.pop()\n\n ", "i", "x", "if i == \"S\":\n sl.append(1)\n else:\n if len(sl) != 0:\n ans += sl.pop()\n\n ", "i == \"S\"", "i", "\"S\"", "sl.append(1)", "sl.append", "sl", "append", "1", "if len(sl) != 0:\n ans += sl.pop()\n\n ", "len(sl) != 0", "len(sl)", "len", "sl", "0", "ans += sl.pop()", "ans", "sl.pop()", "sl.pop", "sl", "pop", "print(len(x) - ans * 2)", "print", "len(x) - ans * 2", "len(x)", "len", "x", "ans * 2", "ans", "2", "ans = 0", "0", "ans", "ans += sl.pop()", "sl.pop()", "ans", "x = list(input())", "list(input())", "x", "sl = []", "[]", "sl" ]
if __name__ == '__main__': x = list(input()) sl = [] ans = 0 for i in x: if i == "S": sl.append(1) else: if len(sl) != 0: ans += sl.pop() print(len(x) - ans * 2)
[ 7, 12, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 29, 2, 17, 13, 23, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 8, 7 ], [ 11, 10 ], [ 34, 10 ], [ 10, 14 ], [ 18, 17 ], [ 7, 21 ], [ 24, 21 ], [ 17, 21 ], [ 25, 24 ], [ 28, 27 ], [ 27, 32 ], [ 4, 32 ], [ 34, 34 ], [ 45, 36 ], [ 49, 42 ], [ 46, 43 ], [ 45, 46 ] ]
[ "def Solver(X):\n K=0\n P=0\n\n for s in X:\n if s==\"S\":\n P+=1\n elif P>0:\n P-=1\n else:\n K+=1\n\n return 2*K\n#================================================\nX=input()\nprint(Solver(X))", "def Solver(X):\n K=0\n P=0\n\n for s in X:\n if s==\"S\":\n P+=1\n elif P>0:\n P-=1\n else:\n K+=1\n\n return 2*K\n#================================================", "Solver", "K=0", "K", "0", "P=0", "P", "0", "for s in X:\n if s==\"S\":\n P+=1\n elif P>0:\n P-=1\n else:\n K+=1\n\n ", "s", "X", "if s==\"S\":\n P+=1\n elif P>0:\n P-=1\n else:\n K+=1\n\n ", "s==\"S\"", "s", "\"S\"", "P+=1", "P", "1", "elif P>0:\n P-=1\n ", "P>0", "P", "0", "P-=1", "P", "1", "K+=1", "K", "1", "return 2*K", "2*K", "2", "K", "X", "X", "X=input()", "X", "input()", "input", "print(Solver(X))", "print", "Solver(X)", "Solver", "X", "X=input()", "input()", "X", "def Solver(X):\n K=0\n P=0\n\n for s in X:\n if s==\"S\":\n P+=1\n elif P>0:\n P-=1\n else:\n K+=1\n\n return 2*K\n#================================================", "def Solver(X):\n K=0\n P=0\n\n for s in X:\n if s==\"S\":\n P+=1\n elif P>0:\n P-=1\n else:\n K+=1\n\n return 2*K\n#================================================", "Solver" ]
def Solver(X): K=0 P=0 for s in X: if s=="S": P+=1 elif P>0: P-=1 else: K+=1 return 2*K #================================================ X=input() print(Solver(X))
[ 7, 0, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 13, 0, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 71, 2 ], [ 77, 9 ], [ 80, 12 ], [ 80, 15 ], [ 19, 18 ], [ 72, 18 ], [ 18, 22 ], [ 83, 25 ], [ 68, 28 ], [ 69, 32 ], [ 81, 32 ], [ 75, 32 ], [ 84, 33 ], [ 66, 33 ], [ 63, 33 ], [ 59, 35 ], [ 84, 36 ], [ 66, 36 ], [ 63, 36 ], [ 74, 38 ], [ 74, 41 ], [ 86, 44 ], [ 63, 47 ], [ 84, 47 ], [ 66, 47 ], [ 75, 48 ], [ 69, 48 ], [ 81, 48 ], [ 72, 54 ], [ 87, 56 ], [ 60, 56 ], [ 78, 56 ], [ 84, 59 ], [ 66, 59 ], [ 63, 59 ], [ 59, 60 ], [ 74, 63 ], [ 80, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ] ]
[ "s = input().rstrip()\n\nremoved = 0\ncnt_s = cnt_t = 0\n\nfor c in s:\n if c == 'S':\n cnt_s += 1\n else:\n cnt_t += 1\n if cnt_t > cnt_s:\n removed += cnt_s\n cnt_s = cnt_t = 0\n# print(cnt_s,cnt_t)\nremoved += min(cnt_s,cnt_t)\nprint(len(s) - removed*2)", "s = input().rstrip()", "s", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "removed = 0", "removed", "0", "cnt_s = cnt_t = 0", "cnt_s", "0", "= cnt_t = 0", "cnt_t", "0", "for c in s:\n if c == 'S':\n cnt_s += 1\n else:\n cnt_t += 1\n if cnt_t > cnt_s:\n removed += cnt_s\n cnt_s = cnt_t = 0\n# print(cnt_s,cnt_t)", "c", "s", "if c == 'S':\n cnt_s += 1\n else:\n cnt_t += 1\n ", "c == 'S'", "c", "'S'", "cnt_s += 1", "cnt_s", "1", "cnt_t += 1", "cnt_t", "1", "if cnt_t > cnt_s:\n removed += cnt_s\n cnt_s = cnt_t = 0\n# print(cnt_s,cnt_t)", "cnt_t > cnt_s", "cnt_t", "cnt_s", "removed += cnt_s", "removed", "cnt_s", "cnt_s = cnt_t = 0", "cnt_s", "0", "= cnt_t = 0", "cnt_t", "0", "removed += min(cnt_s,cnt_t)", "removed", "min(cnt_s,cnt_t)", "min", "cnt_s", "cnt_t", "print(len(s) - removed*2)", "print", "len(s) - removed*2", "len(s)", "len", "s", "removed*2", "removed", "2", "removed += cnt_s", "cnt_s", "removed", "cnt_s = cnt_t = 0", "0", "cnt_s", "cnt_s = cnt_t = 0", "0", "cnt_s", "cnt_t += 1", "1", "cnt_t", "s = input().rstrip()", "input().rstrip()", "s", "cnt_t = 0", "0", "cnt_t", "removed = 0", "0", "removed", "cnt_t = 0", "0", "cnt_t", "cnt_s += 1", "1", "cnt_s", "removed += min(cnt_s,cnt_t)", "min(cnt_s,cnt_t)", "removed" ]
s = input().rstrip() removed = 0 cnt_s = cnt_t = 0 for c in s: if c == 'S': cnt_s += 1 else: cnt_t += 1 if cnt_t > cnt_s: removed += cnt_s cnt_s = cnt_t = 0 # print(cnt_s,cnt_t) removed += min(cnt_s,cnt_t) print(len(s) - removed*2)
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 15, 12, 13, 0, 13, 4, 18, 4, 13, 13, 29, 13, 12, 13, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 14, 2, 2, 4, 13, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 17, 14, 2, 13, 17, 4, 18, 13, 13, 17, 29, 4, 13, 13, 23, 13, 14, 2, 13, 17, 0, 13, 4, 13, 4, 13, 4, 13, 31, 13, 10, 4, 13, 10, 18, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 89, 4 ], [ 15, 14 ], [ 90, 18 ], [ 14, 21 ], [ 26, 25 ], [ 30, 29 ], [ 70, 29 ], [ 29, 33 ], [ 25, 40 ], [ 25, 44 ], [ 25, 49 ], [ 25, 53 ], [ 29, 58 ], [ 25, 62 ], [ 25, 68 ], [ 70, 70 ], [ 86, 76 ], [ 93, 78 ], [ 96, 82 ], [ 87, 84 ], [ 86, 87 ], [ 89, 90 ] ]
[ "import sys\ninput = sys.stdin.readline\nfrom collections import deque\n\n\ndef read():\n X = input().strip()\n return X,\n\n\ndef solve(X):\n q = deque()\n for x in X:\n if x == \"T\":\n if len(q) > 0 and q[-1] == \"S\":\n # remove ST pair\n q.pop()\n else:\n q.append(\"T\")\n elif x == \"S\":\n q.append(\"S\")\n return len(q)\n \n\n\nif __name__ == '__main__':\n inputs = read()\n print(solve(*inputs))", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "from collections import deque", "def read():\n X = input().strip()\n return X,", "read", "X = input().strip()", "X", "input().strip()", "().strip", "()", "input", "strip", "return X,", "X", "def solve(X):\n q = deque()\n for x in X:\n if x == \"T\":\n if len(q) > 0 and q[-1] == \"S\":\n # remove ST pair\n q.pop()\n else:\n q.append(\"T\")\n elif x == \"S\":\n q.append(\"S\")\n return len(q)\n ", "solve", "q = deque()", "q", "deque()", "deque", "for x in X:\n if x == \"T\":\n if len(q) > 0 and q[-1] == \"S\":\n # remove ST pair\n q.pop()\n else:\n q.append(\"T\")\n elif x == \"S\":\n q.append(\"S\")\n ", "x", "X", "if x == \"T\":\n if len(q) > 0 and q[-1] == \"S\":\n # remove ST pair\n q.pop()\n else:\n q.append(\"T\")\n elif x == \"S\":\n q.append(\"S\")\n ", "x == \"T\"", "x", "\"T\"", "if len(q) > 0 and q[-1] == \"S\":\n # remove ST pair\n q.pop()\n else:\n q.append(\"T\")\n ", "len(q) > 0 and q[-1] == \"S\"", "len(q) > 0", "len(q)", "len", "q", "0", "q[-1] == \"S\"", "q[-1]", "q", "-1", "\"S\"", "q.pop()", "q.pop", "q", "pop", "q.append(\"T\")", "q.append", "q", "append", "\"T\"", "elif x == \"S\":\n q.append(\"S\")\n ", "x == \"S\"", "x", "\"S\"", "q.append(\"S\")", "q.append", "q", "append", "\"S\"", "return len(q)", "len(q)", "len", "q", "X", "X", "if __name__ == '__main__':\n inputs = read()\n print(solve(*inputs))", "__name__ == '__main__'", "__name__", "'__main__'", "inputs = read()", "inputs", "read()", "read", "print(solve(*inputs))", "print", "solve(*inputs)", "solve", "*inputs", "inputs", "inputs = read()", "read()", "inputs", "input = sys.stdin.readline", "sys.stdin.readline", "input", "def read():\n X = input().strip()\n return X,", "def read():\n X = input().strip()\n return X,", "read", "def solve(X):\n q = deque()\n for x in X:\n if x == \"T\":\n if len(q) > 0 and q[-1] == \"S\":\n # remove ST pair\n q.pop()\n else:\n q.append(\"T\")\n elif x == \"S\":\n q.append(\"S\")\n return len(q)\n ", "def solve(X):\n q = deque()\n for x in X:\n if x == \"T\":\n if len(q) > 0 and q[-1] == \"S\":\n # remove ST pair\n q.pop()\n else:\n q.append(\"T\")\n elif x == \"S\":\n q.append(\"S\")\n return len(q)\n ", "solve" ]
import sys input = sys.stdin.readline from collections import deque def read(): X = input().strip() return X, def solve(X): q = deque() for x in X: if x == "T": if len(q) > 0 and q[-1] == "S": # remove ST pair q.pop() else: q.append("T") elif x == "S": q.append("S") return len(q) if __name__ == '__main__': inputs = read() print(solve(*inputs))
[ 7, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 2, 4, 13, 13, 17, 17, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 11, 10 ], [ 14, 13 ], [ 17, 16 ], [ 4, 22 ], [ 4, 29 ], [ 16, 30 ], [ 34, 33 ], [ 37, 36 ], [ 4, 42 ], [ 16, 43 ], [ 36, 46 ], [ 13, 46 ], [ 49, 46 ], [ 50, 49 ], [ 53, 52 ], [ 4, 59 ], [ 52, 60 ], [ 10, 60 ], [ 69, 66 ] ]
[ "def main():\n S = str(input())\n ans = 0\n num_t = 0\n for i in range(len(S)-1, -1, -1):\n if S[i] == 'T':\n flag = True\n num_t += 1\n if S[i] == 'S' and num_t > 0 :\n num_t -= 1\n ans += 2\n print(len(S)-ans)\n \nif __name__ == \"__main__\":\n main()", "def main():\n S = str(input())\n ans = 0\n num_t = 0\n for i in range(len(S)-1, -1, -1):\n if S[i] == 'T':\n flag = True\n num_t += 1\n if S[i] == 'S' and num_t > 0 :\n num_t -= 1\n ans += 2\n print(len(S)-ans)\n ", "main", "S = str(input())", "S", "str(input())", "str", "input()", "input", "ans = 0", "ans", "0", "num_t = 0", "num_t", "0", "for i in range(len(S)-1, -1, -1):\n if S[i] == 'T':\n flag = True\n num_t += 1\n if S[i] == 'S' and num_t > 0 :\n num_t -= 1\n ans += 2\n ", "i", "range(len(S)-1, -1, -1)", "range", "len(S)-1", "len(S)", "len", "S", "1", "-1", "-1", "if S[i] == 'T':\n flag = True\n num_t += 1\n ", "S[i] == 'T'", "S[i]", "S", "i", "'T'", "flag = True", "flag", "True", "num_t += 1", "num_t", "1", "if S[i] == 'S' and num_t > 0 :\n num_t -= 1\n ans += 2\n ", "S[i] == 'S' and num_t > 0", "S[i] == 'S'", "S[i]", "S", "i", "'S'", "num_t > 0", "num_t", "0", "num_t -= 1", "num_t", "1", "ans += 2", "ans", "2", "print(len(S)-ans)", "print", "len(S)-ans", "len(S)", "len", "S", "ans", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n S = str(input())\n ans = 0\n num_t = 0\n for i in range(len(S)-1, -1, -1):\n if S[i] == 'T':\n flag = True\n num_t += 1\n if S[i] == 'S' and num_t > 0 :\n num_t -= 1\n ans += 2\n print(len(S)-ans)\n ", "def main():\n S = str(input())\n ans = 0\n num_t = 0\n for i in range(len(S)-1, -1, -1):\n if S[i] == 'T':\n flag = True\n num_t += 1\n if S[i] == 'S' and num_t > 0 :\n num_t -= 1\n ans += 2\n print(len(S)-ans)\n ", "main" ]
def main(): S = str(input()) ans = 0 num_t = 0 for i in range(len(S)-1, -1, -1): if S[i] == 'T': flag = True num_t += 1 if S[i] == 'S' and num_t > 0 : num_t -= 1 ans += 2 print(len(S)-ans) if __name__ == "__main__": main()
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 12, 13, 23, 13, 41, 28, 13, 4, 13, 13, 4, 2, 39, 13, 13, 12, 13, 23, 13, 23, 13, 23, 13, 41, 28, 13, 4, 13, 13, 4, 13, 12, 13, 23, 13, 23, 13, 23, 13, 23, 13, 0, 13, 4, 13, 17, 15, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 13, 17, 14, 2, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13 ]
[ [ 19, 18 ], [ 40, 40 ], [ 44, 43 ], [ 55, 55 ], [ 57, 57 ], [ 59, 59 ], [ 63, 62 ], [ 71, 71 ], [ 73, 73 ], [ 75, 75 ], [ 77, 77 ], [ 148, 79 ], [ 142, 85 ], [ 90, 89 ], [ 149, 89 ], [ 89, 93 ], [ 143, 97 ], [ 89, 99 ], [ 89, 102 ], [ 143, 106 ], [ 143, 109 ], [ 143, 114 ], [ 143, 118 ], [ 89, 120 ], [ 143, 125 ], [ 142, 143 ], [ 148, 149 ] ]
[ "import sys\nsys.setrecursionlimit(10**8)\ndef ii(): return int(sys.stdin.readline())\ndef mi(): return map(int, sys.stdin.readline().split())\ndef li(): return list(map(int, sys.stdin.readline().split()))\ndef li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for _ in range(j)]\ndef dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))\n\nS = input()\n'''\ns_cnt = 0\nfor m in S:\n if m == 'S':\n s_cnt += 1\n elif m == 'T' and s_cnt > 0:\n s_cnt -= 1\n\nprint(2 * s_cnt)\n'''\nfrom collections import deque\nans = deque()\nfor m in S:\n if m == 'S':\n ans.append(m)\n elif m == 'T':\n if ans and ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(m)\nprint(len(ans))", "import sys", "sys", "sys.setrecursionlimit(10**8)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**8", "10", "8", "def ii(): return int(sys.stdin.readline())", "ii", "def mi(): return map(int, sys.stdin.readline().split())", "mi", "def li(): return list(map(int, sys.stdin.readline().split()))", "li", "list(map(int, sys.stdin.readline().split())) for _ in range(N)", "for _ in range(N)", "_", "range(N)", "range", "N", "for _ in range(N)", "list(map(int, sys.stdin.readline().split()))", "list", "map(int, sys.stdin.readline().split())", "map", "int", "sys.stdin.readline().split()", "sys.stdin.readline().split", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "split", "def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]", "li2", "N", "N", "[ini]*i for _ in range(j)", "for _ in range(j)", "_", "range(j)", "range", "j", "for _ in range(j)", "[ini]*i", "[ini]", "ini", "i", "def dp2(ini, i, j): return [[ini]*i for _ in range(j)]", "dp2", "ini", "ini", "i", "i", "j", "j", "[[ini]*i for _ in range(j)] for _ in range(k)", "for _ in range(k)", "_", "range(k)", "range", "k", "for _ in range(k)", "[[ini]*i for _ in range(j)]", "def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))", "dp3", "ini", "ini", "i", "i", "j", "j", "k", "k", "S = input()", "S", "input()", "input", "'''\ns_cnt = 0\nfor m in S:\n if m == 'S':\n s_cnt += 1\n elif m == 'T' and s_cnt > 0:\n s_cnt -= 1\n\nprint(2 * s_cnt)\n'''", "from collections import deque", "ans = deque()", "ans", "deque()", "deque", "for m in S:\n if m == 'S':\n ans.append(m)\n elif m == 'T':\n if ans and ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(m)", "m", "S", "if m == 'S':\n ans.append(m)\n elif m == 'T':\n if ans and ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(m)", "m == 'S'", "m", "'S'", "ans.append(m)", "ans.append", "ans", "append", "m", "elif m == 'T':\n if ans and ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(m)", "m == 'T'", "m", "'T'", "if ans and ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(m)", "ans and ans[-1] == 'S'", "ans", "ans[-1] == 'S'", "ans[-1]", "ans", "-1", "'S'", "ans.pop()", "ans.pop", "ans", "pop", "ans.append(m)", "ans.append", "ans", "append", "m", "print(len(ans))", "print", "len(ans)", "len", "ans", "def li(): return list(map(int, sys.stdin.readline().split()))", "def li(): return list(map(int, sys.stdin.readline().split()))", "li", "def ii(): return int(sys.stdin.readline())", "def ii(): return int(sys.stdin.readline())", "ii", "def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]", "def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]", "li2", "def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))", "def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from itertools import accumulate #list(accumulate(A))", "dp3", "def mi(): return map(int, sys.stdin.readline().split())", "def mi(): return map(int, sys.stdin.readline().split())", "mi", "ans = deque()", "deque()", "ans", "def dp2(ini, i, j): return [[ini]*i for _ in range(j)]", "def dp2(ini, i, j): return [[ini]*i for _ in range(j)]", "dp2", "S = input()", "input()", "S" ]
import sys sys.setrecursionlimit(10**8) def ii(): return int(sys.stdin.readline()) def mi(): return map(int, sys.stdin.readline().split()) def li(): return list(map(int, sys.stdin.readline().split())) def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)] def dp2(ini, i, j): return [[ini]*i for _ in range(j)] def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)] #import bisect #bisect.bisect_left(B, a) #from collections import defaultdict #d = defaultdict(int) d[key] += value #from itertools import accumulate #list(accumulate(A)) S = input() ''' s_cnt = 0 for m in S: if m == 'S': s_cnt += 1 elif m == 'T' and s_cnt > 0: s_cnt -= 1 print(2 * s_cnt) ''' from collections import deque ans = deque() for m in S: if m == 'S': ans.append(m) elif m == 'T': if ans and ans[-1] == 'S': ans.pop() else: ans.append(m) print(len(ans))
[ 7, 15, 13, 12, 13, 29, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 9, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 26, 25 ], [ 71, 27 ], [ 30, 29 ], [ 25, 32 ], [ 35, 34 ], [ 38, 37 ], [ 25, 37 ], [ 37, 41 ], [ 45, 44 ], [ 44, 49 ], [ 34, 49 ], [ 52, 49 ], [ 53, 52 ], [ 56, 55 ], [ 55, 59 ], [ 29, 59 ], [ 68, 65 ] ]
[ "import sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nsys.setrecursionlimit(10 ** 9)\n\n\ndef main():\n X = input()\n answer = len(X)\n cnt_s = 0\n for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n answer -= 2\n \n print(answer)\n\n\nif __name__ == \"__main__\":\n main()", "import sys", "sys", "def input():\n return sys.stdin.readline().strip()", "input", "return sys.stdin.readline().strip()", "sys.stdin.readline().strip()", "sys.stdin.readline().strip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "strip", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "def main():\n X = input()\n answer = len(X)\n cnt_s = 0\n for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n answer -= 2\n \n print(answer)", "main", "X = input()", "X", "input()", "input", "answer = len(X)", "answer", "len(X)", "len", "X", "cnt_s = 0", "cnt_s", "0", "for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n answer -= 2\n \n ", "x", "X", "if x == \"S\":\n cnt_s += 1\n continue\n ", "x == \"S\"", "x", "\"S\"", "cnt_s += 1", "cnt_s", "1", "continue", "if cnt_s > 0:\n cnt_s -= 1\n answer -= 2\n \n ", "cnt_s > 0", "cnt_s", "0", "cnt_s -= 1", "cnt_s", "1", "answer -= 2", "answer", "2", "print(answer)", "print", "answer", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n X = input()\n answer = len(X)\n cnt_s = 0\n for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n answer -= 2\n \n print(answer)", "def main():\n X = input()\n answer = len(X)\n cnt_s = 0\n for x in X:\n if x == \"S\":\n cnt_s += 1\n continue\n if cnt_s > 0:\n cnt_s -= 1\n answer -= 2\n \n print(answer)", "main", "def input():\n return sys.stdin.readline().strip()", "def input():\n return sys.stdin.readline().strip()", "input" ]
import sys def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10 ** 9) def main(): X = input() answer = len(X) cnt_s = 0 for x in X: if x == "S": cnt_s += 1 continue if cnt_s > 0: cnt_s -= 1 answer -= 2 print(answer) if __name__ == "__main__": main()
[ 7, 0, 13, 17, 28, 13, 4, 13, 4, 13, 2, 17, 13, 10, 17, 13 ]
[ [ 14, 2 ], [ 6, 5 ], [ 15, 12 ], [ 14, 15 ] ]
[ "s=0\nfor x in input():s+=x<'T'or-(s>0)\nprint(2*s)", "s=0", "s", "0", "for x in input():s+=x<'T'or-(s>0)", "x", "input()", "input", "print(2*s)", "print", "2*s", "2", "s", "s=0", "0", "s" ]
s=0 for x in input():s+=x<'T'or-(s>0) print(2*s)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 17, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 4, 18, 13, 13, 13, 4, 13, 2, 4, 13, 13, 17, 10, 4, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 53, 2 ], [ 50, 6 ], [ 54, 9 ], [ 56, 11 ], [ 16, 15 ], [ 51, 15 ], [ 54, 15 ], [ 15, 19 ], [ 57, 23 ], [ 15, 25 ], [ 57, 29 ], [ 57, 34 ], [ 57, 39 ], [ 15, 41 ], [ 57, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "s=input()\n\ns=list(s)\n\nans = ['G']\n\nfor i in s:\n if i == 'S':\n ans.append(i)\n else:\n if ans[-1] == 'S':\n ans.pop(-1)\n else:\n ans.append(i)\nprint(len(ans)-1)", "s=input()", "s", "input()", "input", "s=list(s)", "s", "list(s)", "list", "s", "ans = ['G']", "ans", "['G']", "'G'", "for i in s:\n if i == 'S':\n ans.append(i)\n else:\n if ans[-1] == 'S':\n ans.pop(-1)\n else:\n ans.append(i)", "i", "s", "if i == 'S':\n ans.append(i)\n else:\n if ans[-1] == 'S':\n ans.pop(-1)\n else:\n ans.append(i)", "i == 'S'", "i", "'S'", "ans.append(i)", "ans.append", "ans", "append", "i", "if ans[-1] == 'S':\n ans.pop(-1)\n else:\n ans.append(i)", "ans[-1] == 'S'", "ans[-1]", "ans", "-1", "'S'", "ans.pop(-1)", "ans.pop", "ans", "pop", "-1", "ans.append(i)", "ans.append", "ans", "append", "i", "print(len(ans)-1)", "print", "len(ans)-1", "len(ans)", "len", "ans", "1", "s=list(s)", "list(s)", "s", "s=input()", "input()", "s", "ans = ['G']", "['G']", "ans" ]
s=input() s=list(s) ans = ['G'] for i in s: if i == 'S': ans.append(i) else: if ans[-1] == 'S': ans.pop(-1) else: ans.append(i) print(len(ans)-1)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 40, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 53, 2 ], [ 44, 6 ], [ 54, 9 ], [ 47, 11 ], [ 15, 14 ], [ 54, 14 ], [ 14, 18 ], [ 56, 21 ], [ 14, 26 ], [ 57, 29 ], [ 48, 29 ], [ 51, 29 ], [ 50, 32 ], [ 41, 35 ], [ 42, 39 ], [ 45, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "X=input()\nans=len(X)\ncount_s=0\nfor i in X:\n if i=='S':\n count_s+=1\n if i=='T' and count_s>=1:\n count_s-=1\n ans-=2\n\nprint(ans)", "X=input()", "X", "input()", "input", "ans=len(X)", "ans", "len(X)", "len", "X", "count_s=0", "count_s", "0", "for i in X:\n if i=='S':\n count_s+=1\n if i=='T' and count_s>=1:\n count_s-=1\n ans-=2", "i", "X", "if i=='S':\n count_s+=1\n ", "i=='S'", "i", "'S'", "count_s+=1", "count_s", "1", "if i=='T' and count_s>=1:\n count_s-=1\n ans-=2", "i=='T' and count_s>=1", "i=='T'", "i", "'T'", "count_s>=1", "count_s", "1", "count_s-=1", "count_s", "1", "ans-=2", "ans", "2", "print(ans)", "print", "ans", "ans-=2", "2", "ans", "ans=len(X)", "len(X)", "ans", "count_s=0", "0", "count_s", "count_s-=1", "1", "count_s", "X=input()", "input()", "X", "count_s+=1", "1", "count_s" ]
X=input() ans=len(X) count_s=0 for i in X: if i=='S': count_s+=1 if i=='T' and count_s>=1: count_s-=1 ans-=2 print(ans)
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 12, 11 ], [ 15, 14 ], [ 4, 14 ], [ 14, 18 ], [ 22, 21 ], [ 27, 26 ], [ 30, 29 ], [ 4, 36 ], [ 26, 37 ], [ 11, 37 ], [ 46, 43 ] ]
[ "def main():\n X = input()\n S_COUNT = 0\n delete = 0\n for c in X:\n if c == \"S\":\n S_COUNT += 1\n else:\n if S_COUNT:\n delete += 2\n S_COUNT -= 1\n \n print(len(X)-delete)\nif __name__ == \"__main__\":\n main()", "def main():\n X = input()\n S_COUNT = 0\n delete = 0\n for c in X:\n if c == \"S\":\n S_COUNT += 1\n else:\n if S_COUNT:\n delete += 2\n S_COUNT -= 1\n \n print(len(X)-delete)", "main", "X = input()", "X", "input()", "input", "S_COUNT = 0", "S_COUNT", "0", "delete = 0", "delete", "0", "for c in X:\n if c == \"S\":\n S_COUNT += 1\n else:\n if S_COUNT:\n delete += 2\n S_COUNT -= 1\n \n ", "c", "X", "if c == \"S\":\n S_COUNT += 1\n else:\n if S_COUNT:\n delete += 2\n S_COUNT -= 1\n \n ", "c == \"S\"", "c", "\"S\"", "S_COUNT += 1", "S_COUNT", "1", "if S_COUNT:\n delete += 2\n S_COUNT -= 1\n \n ", "S_COUNT", "delete += 2", "delete", "2", "S_COUNT -= 1", "S_COUNT", "1", "print(len(X)-delete)", "print", "len(X)-delete", "len(X)", "len", "X", "delete", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n X = input()\n S_COUNT = 0\n delete = 0\n for c in X:\n if c == \"S\":\n S_COUNT += 1\n else:\n if S_COUNT:\n delete += 2\n S_COUNT -= 1\n \n print(len(X)-delete)", "def main():\n X = input()\n S_COUNT = 0\n delete = 0\n for c in X:\n if c == \"S\":\n S_COUNT += 1\n else:\n if S_COUNT:\n delete += 2\n S_COUNT -= 1\n \n print(len(X)-delete)", "main" ]
def main(): X = input() S_COUNT = 0 delete = 0 for c in X: if c == "S": S_COUNT += 1 else: if S_COUNT: delete += 2 S_COUNT -= 1 print(len(X)-delete) if __name__ == "__main__": main()
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 37, 2 ], [ 46, 6 ], [ 49, 9 ], [ 38, 12 ], [ 15, 14 ], [ 38, 14 ], [ 14, 18 ], [ 40, 21 ], [ 47, 25 ], [ 44, 25 ], [ 41, 25 ], [ 52, 28 ], [ 43, 31 ], [ 53, 35 ], [ 50, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "s = input()\nS = 0\n\nans = len(s)\nfor i in s:\n if i == \"S\":\n S += 1\n else:\n if S > 0:\n ans -= 2\n S -= 1\nprint(ans)", "s = input()", "s", "input()", "input", "S = 0", "S", "0", "ans = len(s)", "ans", "len(s)", "len", "s", "for i in s:\n if i == \"S\":\n S += 1\n else:\n if S > 0:\n ans -= 2\n S -= 1", "i", "s", "if i == \"S\":\n S += 1\n else:\n if S > 0:\n ans -= 2\n S -= 1", "i == \"S\"", "i", "\"S\"", "S += 1", "S", "1", "if S > 0:\n ans -= 2\n S -= 1", "S > 0", "S", "0", "ans -= 2", "ans", "2", "S -= 1", "S", "1", "print(ans)", "print", "ans", "s = input()", "input()", "s", "S += 1", "1", "S", "S -= 1", "1", "S", "S = 0", "0", "S", "ans = len(s)", "len(s)", "ans", "ans -= 2", "2", "ans" ]
s = input() S = 0 ans = len(s) for i in s: if i == "S": S += 1 else: if S > 0: ans -= 2 S -= 1 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 40, 13, 4, 18, 13, 13, 13, 9, 14, 2, 2, 18, 13, 17, 17, 2, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 48, 2 ], [ 45, 6 ], [ 10, 9 ], [ 49, 9 ], [ 46, 13 ], [ 46, 16 ], [ 9, 18 ], [ 46, 24 ], [ 9, 28 ], [ 46, 32 ], [ 46, 36 ], [ 9, 38 ], [ 46, 43 ], [ 45, 46 ], [ 48, 49 ] ]
[ "X = input()\nstack = []\nfor c in X:\n if not stack:\n stack.append(c)\n continue\n if stack[-1] == \"S\" and c == \"T\":\n stack.pop()\n else:\n stack.append(c)\nprint(len(stack))", "X = input()", "X", "input()", "input", "stack = []", "stack", "[]", "for c in X:\n if not stack:\n stack.append(c)\n continue\n if stack[-1] == \"S\" and c == \"T\":\n stack.pop()\n else:\n stack.append(c)", "c", "X", "if not stack:\n stack.append(c)\n continue\n ", "not stack", "stack", "stack.append(c)", "stack.append", "stack", "append", "c", "continue", "if stack[-1] == \"S\" and c == \"T\":\n stack.pop()\n else:\n stack.append(c)", "stack[-1] == \"S\" and c == \"T\"", "stack[-1] == \"S\"", "stack[-1]", "stack", "-1", "\"S\"", "c == \"T\"", "c", "\"T\"", "stack.pop()", "stack.pop", "stack", "pop", "stack.append(c)", "stack.append", "stack", "append", "c", "print(len(stack))", "print", "len(stack)", "len", "stack", "stack = []", "[]", "stack", "X = input()", "input()", "X" ]
X = input() stack = [] for c in X: if not stack: stack.append(c) continue if stack[-1] == "S" and c == "T": stack.pop() else: stack.append(c) print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 49, 2 ], [ 46, 6 ], [ 52, 9 ], [ 13, 12 ], [ 50, 12 ], [ 12, 16 ], [ 40, 19 ], [ 58, 22 ], [ 59, 26 ], [ 41, 26 ], [ 47, 26 ], [ 56, 26 ], [ 43, 29 ], [ 55, 32 ], [ 44, 37 ], [ 53, 37 ], [ 56, 38 ], [ 59, 38 ], [ 41, 38 ], [ 47, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "x=input()\ncnt=0\nans=0\nfor s in x:\n if s==\"T\":\n cnt-=1\n else:\n cnt+=1\n if cnt<0:\n ans+=1\n cnt=0\nprint(ans+cnt)", "x=input()", "x", "input()", "input", "cnt=0", "cnt", "0", "ans=0", "ans", "0", "for s in x:\n if s==\"T\":\n cnt-=1\n else:\n cnt+=1\n if cnt<0:\n ans+=1\n cnt=0", "s", "x", "if s==\"T\":\n cnt-=1\n else:\n cnt+=1\n ", "s==\"T\"", "s", "\"T\"", "cnt-=1", "cnt", "1", "cnt+=1", "cnt", "1", "if cnt<0:\n ans+=1\n cnt=0", "cnt<0", "cnt", "0", "ans+=1", "ans", "1", "cnt=0", "cnt", "0", "print(ans+cnt)", "print", "ans+cnt", "ans", "cnt", "cnt-=1", "1", "cnt", "ans+=1", "1", "ans", "cnt=0", "0", "cnt", "x=input()", "input()", "x", "ans=0", "0", "ans", "cnt=0", "0", "cnt", "cnt+=1", "1", "cnt" ]
x=input() cnt=0 ans=0 for s in x: if s=="T": cnt-=1 else: cnt+=1 if cnt<0: ans+=1 cnt=0 print(ans+cnt)
[ 7, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 2, 13, 17, 14, 2, 18, 13, 13, 17, 14, 40, 13, 17, 0, 13, 2, 13, 17, 0, 13, 2, 13, 17, 4, 13, 2, 13, 2, 17, 13, 10, 17, 13, 10, 2, 13, 10, 2, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 71, 2 ], [ 62, 5 ], [ 80, 8 ], [ 77, 14 ], [ 81, 17 ], [ 20, 19 ], [ 78, 22 ], [ 81, 26 ], [ 19, 27 ], [ 65, 30 ], [ 63, 32 ], [ 69, 32 ], [ 66, 32 ], [ 81, 37 ], [ 19, 38 ], [ 63, 42 ], [ 69, 42 ], [ 66, 42 ], [ 74, 45 ], [ 72, 47 ], [ 75, 47 ], [ 68, 50 ], [ 63, 52 ], [ 69, 52 ], [ 66, 52 ], [ 78, 57 ], [ 75, 60 ], [ 72, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ] ]
[ "L=0\nR=0\nX=list(input())\nA=len(X)\nfor i in range(A):\n if X[i]==\"S\":\n R=R+1\n elif X[i]==\"T\":\n if R!=0:\n L=L+1\n R=R-1\nprint(A-2*L)", "L=0", "L", "0", "R=0", "R", "0", "X=list(input())", "X", "list(input())", "list", "input()", "input", "A=len(X)", "A", "len(X)", "len", "X", "for i in range(A):\n if X[i]==\"S\":\n R=R+1\n elif X[i]==\"T\":\n if R!=0:\n L=L+1\n R=R-1", "i", "range(A)", "range", "A", "if X[i]==\"S\":\n R=R+1\n elif X[i]==\"T\":\n if R!=0:\n L=L+1\n R=R-1", "X[i]==\"S\"", "X[i]", "X", "i", "\"S\"", "R=R+1", "R", "R+1", "R", "1", "elif X[i]==\"T\":\n if R!=0:\n L=L+1\n R=R-1", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "if R!=0:\n L=L+1\n R=R-1", "R!=0", "R", "0", "L=L+1", "L", "L+1", "L", "1", "R=R-1", "R", "R-1", "R", "1", "print(A-2*L)", "print", "A-2*L", "A", "2*L", "2", "L", "R=0", "0", "R", "R=R+1", "R+1", "R", "R=R-1", "R-1", "R", "L=0", "0", "L", "L=L+1", "L+1", "L", "A=len(X)", "len(X)", "A", "X=list(input())", "list(input())", "X" ]
L=0 R=0 X=list(input()) A=len(X) for i in range(A): if X[i]=="S": R=R+1 elif X[i]=="T": if R!=0: L=L+1 R=R-1 print(A-2*L)
[ 7, 0, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 64, 2 ], [ 52, 9 ], [ 65, 12 ], [ 67, 14 ], [ 73, 17 ], [ 21, 20 ], [ 53, 23 ], [ 65, 27 ], [ 20, 28 ], [ 58, 31 ], [ 68, 35 ], [ 62, 35 ], [ 56, 35 ], [ 59, 35 ], [ 70, 38 ], [ 68, 39 ], [ 62, 39 ], [ 56, 39 ], [ 59, 39 ], [ 55, 41 ], [ 61, 44 ], [ 71, 50 ], [ 74, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 68, 70 ], [ 62, 70 ], [ 56, 70 ], [ 59, 70 ], [ 70, 71 ], [ 73, 74 ] ]
[ "X = input().strip()\nN = len(X)\ncnt = 0\ntot = 0\nfor i in range(N):\n if X[i]==\"T\":\n cnt += 1\n else:\n if cnt>0:\n tot += cnt\n cnt = -1\n else:\n cnt -= 1\nprint(2*tot)", "X = input().strip()", "X", "input().strip()", "().strip", "()", "input", "strip", "N = len(X)", "N", "len(X)", "len", "X", "cnt = 0", "cnt", "0", "tot = 0", "tot", "0", "for i in range(N):\n if X[i]==\"T\":\n cnt += 1\n else:\n if cnt>0:\n tot += cnt\n cnt = -1\n else:\n cnt -= 1", "i", "range(N)", "range", "N", "if X[i]==\"T\":\n cnt += 1\n else:\n if cnt>0:\n tot += cnt\n cnt = -1\n else:\n cnt -= 1", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "cnt += 1", "cnt", "1", "if cnt>0:\n tot += cnt\n cnt = -1\n else:\n cnt -= 1", "cnt>0", "cnt", "0", "tot += cnt", "tot", "cnt", "cnt = -1", "cnt", "-1", "cnt -= 1", "cnt", "1", "print(2*tot)", "print", "2*tot", "2", "tot", "N = len(X)", "len(X)", "N", "cnt = -1", "-1", "cnt", "cnt += 1", "1", "cnt", "cnt -= 1", "1", "cnt", "X = input().strip()", "input().strip()", "X", "cnt = 0", "0", "cnt", "tot += cnt", "cnt", "tot", "tot = 0", "0", "tot" ]
X = input().strip() N = len(X) cnt = 0 tot = 0 for i in range(N): if X[i]=="T": cnt += 1 else: if cnt>0: tot += cnt cnt = -1 else: cnt -= 1 print(2*tot)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 56, 2 ], [ 59, 6 ], [ 62, 9 ], [ 13, 12 ], [ 57, 17 ], [ 57, 21 ], [ 12, 22 ], [ 65, 25 ], [ 57, 30 ], [ 12, 31 ], [ 66, 35 ], [ 60, 35 ], [ 54, 35 ], [ 68, 38 ], [ 53, 41 ], [ 57, 48 ], [ 69, 50 ], [ 63, 50 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "s = input()\ncur = 0\ndeletedpairs = 0\nfor i in range(len(s)):\n #print(i, deletedpairs)\n if s[i] == \"S\":\n cur += 1\n if s[i] == \"T\":\n if cur > 0:\n deletedpairs += 1\n cur -= 1\n else:\n pass\n\n#print(deletedpairs)\nprint(len(s) - deletedpairs*2)", "s = input()", "s", "input()", "input", "cur = 0", "cur", "0", "deletedpairs = 0", "deletedpairs", "0", "for i in range(len(s)):\n #print(i, deletedpairs)\n if s[i] == \"S\":\n cur += 1\n if s[i] == \"T\":\n if cur > 0:\n deletedpairs += 1\n cur -= 1\n else:\n pass\n\n#print(deletedpairs)", "i", "range(len(s))", "range", "len(s)", "len", "s", "if s[i] == \"S\":\n cur += 1\n ", "s[i] == \"S\"", "s[i]", "s", "i", "\"S\"", "cur += 1", "cur", "1", "if s[i] == \"T\":\n if cur > 0:\n deletedpairs += 1\n cur -= 1\n else:\n pass\n\n#print(deletedpairs)", "s[i] == \"T\"", "s[i]", "s", "i", "\"T\"", "if cur > 0:\n deletedpairs += 1\n cur -= 1\n else:\n pass\n\n#print(deletedpairs)", "cur > 0", "cur", "0", "deletedpairs += 1", "deletedpairs", "1", "cur -= 1", "cur", "1", "print(len(s) - deletedpairs*2)", "print", "len(s) - deletedpairs*2", "len(s)", "len", "s", "deletedpairs*2", "deletedpairs", "2", "cur -= 1", "1", "cur", "s = input()", "input()", "s", "cur = 0", "0", "cur", "deletedpairs = 0", "0", "deletedpairs", "cur += 1", "1", "cur", "deletedpairs += 1", "1", "deletedpairs" ]
s = input() cur = 0 deletedpairs = 0 for i in range(len(s)): #print(i, deletedpairs) if s[i] == "S": cur += 1 if s[i] == "T": if cur > 0: deletedpairs += 1 cur -= 1 else: pass #print(deletedpairs) print(len(s) - deletedpairs*2)
[ 7, 0, 13, 4, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 13, 17, 14, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 67, 2 ], [ 64, 10 ], [ 68, 13 ], [ 61, 15 ], [ 19, 18 ], [ 68, 18 ], [ 18, 22 ], [ 62, 26 ], [ 18, 28 ], [ 18, 31 ], [ 62, 38 ], [ 62, 43 ], [ 62, 47 ], [ 18, 49 ], [ 62, 52 ], [ 18, 54 ], [ 62, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "X = list(str(input()))\nn = len(X)\n\ns = []\nfor x in X:\n if x == 'S':\n s.append(x)\n if x == 'T':\n if s:\n if s[-1] == 'S':\n s.pop()\n else:\n s.append(x)\n else:\n s.append(x)\nprint(len(s))", "X = list(str(input()))", "X", "list(str(input()))", "list", "str(input())", "str", "input()", "input", "n = len(X)", "n", "len(X)", "len", "X", "s = []", "s", "[]", "for x in X:\n if x == 'S':\n s.append(x)\n if x == 'T':\n if s:\n if s[-1] == 'S':\n s.pop()\n else:\n s.append(x)\n else:\n s.append(x)", "x", "X", "if x == 'S':\n s.append(x)\n ", "x == 'S'", "x", "'S'", "s.append(x)", "s.append", "s", "append", "x", "if x == 'T':\n if s:\n if s[-1] == 'S':\n s.pop()\n else:\n s.append(x)\n else:\n s.append(x)", "x == 'T'", "x", "'T'", "if s:\n if s[-1] == 'S':\n s.pop()\n else:\n s.append(x)\n else:\n s.append(x)", "s", "if s[-1] == 'S':\n s.pop()\n else:\n s.append(x)\n ", "s[-1] == 'S'", "s[-1]", "s", "-1", "'S'", "s.pop()", "s.pop", "s", "pop", "s.append(x)", "s.append", "s", "append", "x", "s.append(x)", "s.append", "s", "append", "x", "print(len(s))", "print", "len(s)", "len", "s", "s = []", "[]", "s", "n = len(X)", "len(X)", "n", "X = list(str(input()))", "list(str(input()))", "X" ]
X = list(str(input())) n = len(X) s = [] for x in X: if x == 'S': s.append(x) if x == 'T': if s: if s[-1] == 'S': s.pop() else: s.append(x) else: s.append(x) print(len(s))
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 48, 2 ], [ 54, 6 ], [ 51, 9 ], [ 13, 12 ], [ 49, 17 ], [ 49, 21 ], [ 12, 22 ], [ 63, 25 ], [ 49, 30 ], [ 12, 31 ], [ 57, 34 ], [ 60, 37 ], [ 52, 40 ], [ 61, 40 ], [ 58, 41 ], [ 64, 41 ], [ 55, 41 ], [ 61, 45 ], [ 52, 45 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "s=input()\nc=0\nans=0\nfor i in range(len(s)):\n if s[i]=='T':\n c+=1\n if s[i]=='S':\n c-=1\n ans = max(ans,c)\nprint(ans*2)", "s=input()", "s", "input()", "input", "c=0", "c", "0", "ans=0", "ans", "0", "for i in range(len(s)):\n if s[i]=='T':\n c+=1\n if s[i]=='S':\n c-=1\n ans = max(ans,c)", "i", "range(len(s))", "range", "len(s)", "len", "s", "if s[i]=='T':\n c+=1\n ", "s[i]=='T'", "s[i]", "s", "i", "'T'", "c+=1", "c", "1", "if s[i]=='S':\n c-=1\n ", "s[i]=='S'", "s[i]", "s", "i", "'S'", "c-=1", "c", "1", "ans = max(ans,c)", "ans", "max(ans,c)", "max", "ans", "c", "print(ans*2)", "print", "ans*2", "ans", "2", "s=input()", "input()", "s", "ans=0", "0", "ans", "c=0", "0", "c", "c-=1", "1", "c", "ans = max(ans,c)", "max(ans,c)", "ans", "c+=1", "1", "c" ]
s=input() c=0 ans=0 for i in range(len(s)): if s[i]=='T': c+=1 if s[i]=='S': c-=1 ans = max(ans,c) print(ans*2)
[ 7, 15, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 2, 13, 17, 2, 2, 4, 13, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 6, 5 ], [ 10, 9 ], [ 14, 13 ], [ 5, 13 ], [ 13, 17 ], [ 9, 21 ], [ 13, 23 ], [ 13, 27 ], [ 9, 33 ], [ 9, 37 ], [ 9, 42 ], [ 13, 44 ], [ 9, 47 ], [ 9, 53 ], [ 62, 59 ] ]
[ "from collections import deque\n\n\ndef main():\n word = input()\n stack = deque()\n for w in word:\n if w == \"S\":\n stack.appendleft(w)\n elif w == \"T\" and (len(stack) == 0 or stack[0] == \"T\"):\n stack.appendleft(w)\n else:\n stack.popleft()\n print(len(stack))\n\n\nif __name__ == '__main__':\n main()\n", "from collections import deque", "def main():\n word = input()\n stack = deque()\n for w in word:\n if w == \"S\":\n stack.appendleft(w)\n elif w == \"T\" and (len(stack) == 0 or stack[0] == \"T\"):\n stack.appendleft(w)\n else:\n stack.popleft()\n print(len(stack))", "main", "word = input()", "word", "input()", "input", "stack = deque()", "stack", "deque()", "deque", "for w in word:\n if w == \"S\":\n stack.appendleft(w)\n elif w == \"T\" and (len(stack) == 0 or stack[0] == \"T\"):\n stack.appendleft(w)\n else:\n stack.popleft()\n ", "w", "word", "if w == \"S\":\n stack.appendleft(w)\n elif w == \"T\" and (len(stack) == 0 or stack[0] == \"T\"):\n stack.appendleft(w)\n else:\n stack.popleft()\n ", "w == \"S\"", "w", "\"S\"", "stack.appendleft(w)", "stack.appendleft", "stack", "appendleft", "w", "elif w == \"T\" and (len(stack) == 0 or stack[0] == \"T\"):\n stack.appendleft(w)\n ", "w == \"T\" and (len(stack) == 0 or stack[0] == \"T\")", "w == \"T\"", "w", "\"T\"", "len(stack) == 0 or stack[0] == \"T\"", "len(stack) == 0", "len(stack)", "len", "stack", "0", "stack[0] == \"T\"", "stack[0]", "stack", "0", "\"T\"", "stack.appendleft(w)", "stack.appendleft", "stack", "appendleft", "w", "stack.popleft()", "stack.popleft", "stack", "popleft", "print(len(stack))", "print", "len(stack)", "len", "stack", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n word = input()\n stack = deque()\n for w in word:\n if w == \"S\":\n stack.appendleft(w)\n elif w == \"T\" and (len(stack) == 0 or stack[0] == \"T\"):\n stack.appendleft(w)\n else:\n stack.popleft()\n print(len(stack))", "def main():\n word = input()\n stack = deque()\n for w in word:\n if w == \"S\":\n stack.appendleft(w)\n elif w == \"T\" and (len(stack) == 0 or stack[0] == \"T\"):\n stack.appendleft(w)\n else:\n stack.popleft()\n print(len(stack))", "main" ]
from collections import deque def main(): word = input() stack = deque() for w in word: if w == "S": stack.appendleft(w) elif w == "T" and (len(stack) == 0 or stack[0] == "T"): stack.appendleft(w) else: stack.popleft() print(len(stack)) if __name__ == '__main__': main()
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 12, 11 ], [ 4, 14 ], [ 17, 16 ], [ 4, 16 ], [ 16, 20 ], [ 24, 23 ], [ 8, 27 ], [ 30, 27 ], [ 23, 27 ], [ 31, 30 ], [ 34, 33 ], [ 33, 37 ], [ 11, 37 ], [ 46, 43 ] ]
[ "def main():\n X = input()\n s = 0\n ans = len(X)\n for x in X:\n if x == 'S':\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2\n print(ans)\nif __name__ == '__main__':\n main()", "def main():\n X = input()\n s = 0\n ans = len(X)\n for x in X:\n if x == 'S':\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2\n print(ans)", "main", "X = input()", "X", "input()", "input", "s = 0", "s", "0", "ans = len(X)", "ans", "len(X)", "len", "X", "for x in X:\n if x == 'S':\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2\n ", "x", "X", "if x == 'S':\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2\n ", "x == 'S'", "x", "'S'", "s += 1", "s", "1", "if s > 0:\n s -= 1\n ans -= 2\n ", "s > 0", "s", "0", "s -= 1", "s", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n X = input()\n s = 0\n ans = len(X)\n for x in X:\n if x == 'S':\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2\n print(ans)", "def main():\n X = input()\n s = 0\n ans = len(X)\n for x in X:\n if x == 'S':\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2\n print(ans)", "main" ]
def main(): X = input() s = 0 ans = len(X) for x in X: if x == 'S': s += 1 else: if s > 0: s -= 1 ans -= 2 print(ans) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 51, 2 ], [ 45, 6 ], [ 52, 9 ], [ 63, 11 ], [ 54, 14 ], [ 18, 17 ], [ 46, 20 ], [ 52, 24 ], [ 17, 25 ], [ 60, 28 ], [ 57, 31 ], [ 48, 34 ], [ 58, 37 ], [ 61, 37 ], [ 55, 37 ], [ 64, 38 ], [ 49, 38 ], [ 49, 43 ], [ 64, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "s = input()\nn = len(s)\nmax_cnt = 0\ncnt = 0\nfor i in range(n):\n if s[i] == 'T':\n cnt += 1\n else:\n cnt -= 1\n max_cnt = max(cnt, max_cnt)\nprint(2*max_cnt)", "s = input()", "s", "input()", "input", "n = len(s)", "n", "len(s)", "len", "s", "max_cnt = 0", "max_cnt", "0", "cnt = 0", "cnt", "0", "for i in range(n):\n if s[i] == 'T':\n cnt += 1\n else:\n cnt -= 1\n max_cnt = max(cnt, max_cnt)", "i", "range(n)", "range", "n", "if s[i] == 'T':\n cnt += 1\n else:\n cnt -= 1\n ", "s[i] == 'T'", "s[i]", "s", "i", "'T'", "cnt += 1", "cnt", "1", "cnt -= 1", "cnt", "1", "max_cnt = max(cnt, max_cnt)", "max_cnt", "max(cnt, max_cnt)", "max", "cnt", "max_cnt", "print(2*max_cnt)", "print", "2*max_cnt", "2", "max_cnt", "n = len(s)", "len(s)", "n", "max_cnt = max(cnt, max_cnt)", "max(cnt, max_cnt)", "max_cnt", "s = input()", "input()", "s", "cnt = 0", "0", "cnt", "cnt -= 1", "1", "cnt", "cnt += 1", "1", "cnt", "max_cnt = 0", "0", "max_cnt" ]
s = input() n = len(s) max_cnt = 0 cnt = 0 for i in range(n): if s[i] == 'T': cnt += 1 else: cnt -= 1 max_cnt = max(cnt, max_cnt) print(2*max_cnt)
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 40, 13, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 49, 2 ], [ 52, 6 ], [ 10, 9 ], [ 50, 9 ], [ 9, 13 ], [ 53, 17 ], [ 9, 19 ], [ 53, 22 ], [ 53, 25 ], [ 9, 27 ], [ 53, 31 ], [ 53, 36 ], [ 53, 40 ], [ 9, 42 ], [ 53, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "x = input()\nstack = []\nfor s in x:\n if s == 'S':\n stack.append(s)\n else:\n if not stack:\n stack.append(s)\n elif stack[-1] == 'S':\n stack.pop()\n else:\n stack.append(s)\nprint(len(stack))", "x = input()", "x", "input()", "input", "stack = []", "stack", "[]", "for s in x:\n if s == 'S':\n stack.append(s)\n else:\n if not stack:\n stack.append(s)\n elif stack[-1] == 'S':\n stack.pop()\n else:\n stack.append(s)", "s", "x", "if s == 'S':\n stack.append(s)\n else:\n if not stack:\n stack.append(s)\n elif stack[-1] == 'S':\n stack.pop()\n else:\n stack.append(s)", "s == 'S'", "s", "'S'", "stack.append(s)", "stack.append", "stack", "append", "s", "if not stack:\n stack.append(s)\n elif stack[-1] == 'S':\n stack.pop()\n else:\n stack.append(s)", "not stack", "stack", "stack.append(s)", "stack.append", "stack", "append", "s", "elif stack[-1] == 'S':\n stack.pop()\n ", "stack[-1] == 'S'", "stack[-1]", "stack", "-1", "'S'", "stack.pop()", "stack.pop", "stack", "pop", "stack.append(s)", "stack.append", "stack", "append", "s", "print(len(stack))", "print", "len(stack)", "len", "stack", "x = input()", "input()", "x", "stack = []", "[]", "stack" ]
x = input() stack = [] for s in x: if s == 'S': stack.append(s) else: if not stack: stack.append(s) elif stack[-1] == 'S': stack.pop() else: stack.append(s) print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 13, 17, 14, 2, 18, 13, 17, 17, 28, 13, 13, 4, 13, 13, 14, 2, 13, 17, 0, 13, 13, 3, 0, 13, 13, 14, 40, 4, 13, 13, 13, 28, 13, 13, 4, 13, 18, 13, 39, 13, 14, 2, 13, 17, 0, 13, 17, 9, 14, 2, 13, 17, 14, 2, 18, 13, 2, 2, 13, 13, 17, 17, 14, 40, 13, 13, 0, 13, 2, 17, 2, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 13, 14, 2, 13, 17, 14, 40, 13, 13, 0, 13, 2, 17, 2, 13, 13, 0, 13, 13, 0, 13, 17, 0, 13, 13, 0, 13, 17, 0, 13, 2, 17, 13, 0, 13, 2, 17, 13, 0, 13, 4, 13, 13, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 13, 13, 10, 13, 13, 10, 2, 13, 10, 2, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 13, 13, 10, 2, 13, 10, 13, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 2, 13 ]
[ [ 162, 2 ], [ 198, 6 ], [ 163, 9 ], [ 207, 11 ], [ 210, 14 ], [ 201, 17 ], [ 204, 19 ], [ 163, 24 ], [ 163, 32 ], [ 213, 38 ], [ 219, 42 ], [ 214, 48 ], [ 208, 48 ], [ 199, 49 ], [ 163, 56 ], [ 165, 64 ], [ 163, 74 ], [ 220, 77 ], [ 211, 77 ], [ 205, 83 ], [ 223, 83 ], [ 169, 83 ], [ 160, 83 ], [ 166, 84 ], [ 202, 84 ], [ 178, 84 ], [ 229, 84 ], [ 193, 84 ], [ 216, 86 ], [ 205, 90 ], [ 223, 90 ], [ 169, 90 ], [ 160, 90 ], [ 166, 91 ], [ 202, 91 ], [ 178, 91 ], [ 229, 91 ], [ 193, 91 ], [ 159, 93 ], [ 192, 96 ], [ 228, 99 ], [ 205, 100 ], [ 223, 100 ], [ 169, 100 ], [ 160, 100 ], [ 168, 102 ], [ 177, 105 ], [ 222, 108 ], [ 183, 111 ], [ 184, 115 ], [ 223, 119 ], [ 169, 119 ], [ 160, 119 ], [ 205, 119 ], [ 178, 120 ], [ 229, 120 ], [ 193, 120 ], [ 166, 120 ], [ 202, 120 ], [ 231, 122 ], [ 223, 126 ], [ 169, 126 ], [ 160, 126 ], [ 205, 126 ], [ 178, 127 ], [ 229, 127 ], [ 193, 127 ], [ 166, 127 ], [ 202, 127 ], [ 180, 129 ], [ 178, 130 ], [ 229, 130 ], [ 193, 130 ], [ 166, 130 ], [ 202, 130 ], [ 171, 132 ], [ 195, 135 ], [ 223, 136 ], [ 169, 136 ], [ 160, 136 ], [ 205, 136 ], [ 174, 138 ], [ 189, 141 ], [ 196, 144 ], [ 178, 144 ], [ 229, 144 ], [ 193, 144 ], [ 166, 144 ], [ 202, 144 ], [ 186, 146 ], [ 178, 149 ], [ 229, 149 ], [ 193, 149 ], [ 166, 149 ], [ 202, 149 ], [ 225, 151 ], [ 187, 154 ], [ 190, 154 ], [ 232, 154 ], [ 217, 154 ], [ 214, 154 ], [ 208, 154 ], [ 226, 157 ], [ 159, 160 ], [ 162, 163 ], [ 165, 166 ], [ 168, 169 ], [ 171, 172 ], [ 174, 175 ], [ 177, 178 ], [ 178, 180 ], [ 229, 180 ], [ 193, 180 ], [ 166, 180 ], [ 202, 180 ], [ 180, 181 ], [ 183, 184 ], [ 186, 187 ], [ 189, 190 ], [ 192, 193 ], [ 223, 195 ], [ 169, 195 ], [ 160, 195 ], [ 205, 195 ], [ 195, 196 ], [ 198, 199 ], [ 201, 202 ], [ 204, 205 ], [ 207, 208 ], [ 210, 211 ], [ 213, 214 ], [ 216, 217 ], [ 219, 220 ], [ 222, 223 ], [ 225, 226 ], [ 205, 228 ], [ 223, 228 ], [ 169, 228 ], [ 160, 228 ], [ 228, 229 ], [ 231, 232 ] ]
[ "#!/usr/bin/env python3\n\nX = input()\nN = len(X)\nafter_x = \"\"\nnext_i = 0\n# 連続する箇所で部分文字列を作りたい\ns_count, t_count = 0, 0\nif X[0] == \"T\":\n # Tから始まる場合、最初の連続するTは確定で残るので切り捨てる\n for i, x in enumerate(X):\n if x == \"T\":\n after_x += x\n else:\n break\n next_i = i\n\nif len(after_x) != N:\n # 「全ての文字列がT」ではない\n # 残りの文字列について操作する(最初のTは処理したので、必ずSから始まる)\n for i, char in enumerate(X[next_i:]):\n if i == 0:\n # 最初は確定でSから始まる\n s_count += 1\n continue\n\n if char == \"S\":\n # Sの場合\n if X[next_i + i - 1] == \"T\":\n # T->Sの切り替わりのとき\n if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count = 0\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n s_count += 1\n else:\n # Tの場合\n t_count += 1\n last_char = char\n\n if last_char == \"T\":\n # Tで終わる場合\n if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count -= s_count\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n after_x += \"S\" * s_count\n else:\n # Sで終わる場合\n after_x += \"S\" * s_count\n# print(after_x)\nans = len(after_x)\nprint(ans)", "X = input()", "X", "input()", "input", "N = len(X)", "N", "len(X)", "len", "X", "after_x = \"\"", "after_x", "\"\"", "next_i = 0", "next_i", "0", "s_count, t_count = 0, 0", "s_count", "0", "t_count", "0", "if X[0] == \"T\":\n # Tから始まる場合、最初の連続するTは確定で残るので切り捨てる\n for i, x in enumerate(X):\n if x == \"T\":\n after_x += x\n else:\n break\n next_i = i", "X[0] == \"T\"", "X[0]", "X", "0", "\"T\"", "for i, x in enumerate(X):\n if x == \"T\":\n after_x += x\n else:\n break\n ", "i", "x", "enumerate(X)", "enumerate", "X", "if x == \"T\":\n after_x += x\n else:\n break\n ", "x == \"T\"", "x", "\"T\"", "after_x += x", "after_x", "x", "break", "next_i = i", "next_i", "i", "if len(after_x) != N:\n # 「全ての文字列がT」ではない\n # 残りの文字列について操作する(最初のTは処理したので、必ずSから始まる)\n for i, char in enumerate(X[next_i:]):\n if i == 0:\n # 最初は確定でSから始まる\n s_count += 1\n continue\n\n if char == \"S\":\n # Sの場合\n if X[next_i + i - 1] == \"T\":\n # T->Sの切り替わりのとき\n if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count = 0\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n s_count += 1\n else:\n # Tの場合\n t_count += 1\n last_char = char\n\n if last_char == \"T\":\n # Tで終わる場合\n if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count -= s_count\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n after_x += \"S\" * s_count\n else:\n # Sで終わる場合\n after_x += \"S\" * s_count\n# print(after_x)", "len(after_x) != N", "len(after_x)", "len", "after_x", "N", "for i, char in enumerate(X[next_i:]):\n if i == 0:\n # 最初は確定でSから始まる\n s_count += 1\n continue\n\n if char == \"S\":\n # Sの場合\n if X[next_i + i - 1] == \"T\":\n # T->Sの切り替わりのとき\n if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count = 0\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n s_count += 1\n else:\n # Tの場合\n t_count += 1\n ", "i", "char", "enumerate(X[next_i:])", "enumerate", "X[next_i:]", "X", "next_i:", "next_i", "if i == 0:\n # 最初は確定でSから始まる\n s_count += 1\n continue\n\n ", "i == 0", "i", "0", "s_count += 1", "s_count", "1", "continue", "if char == \"S\":\n # Sの場合\n if X[next_i + i - 1] == \"T\":\n # T->Sの切り替わりのとき\n if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count = 0\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n s_count += 1\n else:\n # Tの場合\n t_count += 1\n ", "char == \"S\"", "char", "\"S\"", "if X[next_i + i - 1] == \"T\":\n # T->Sの切り替わりのとき\n if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count = 0\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n ", "X[next_i + i - 1] == \"T\"", "X[next_i + i - 1]", "X", "next_i + i - 1", "next_i + i", "next_i", "i", "1", "\"T\"", "if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count = 0\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n ", "t_count >= s_count", "t_count", "s_count", "after_x += \"T\" * (t_count - s_count)", "after_x", "\"T\" * (t_count - s_count)", "\"T\"", "t_count - s_count", "t_count", "s_count", "t_count = 0", "t_count", "0", "s_count = 0", "s_count", "0", "s_count -= t_count", "s_count", "t_count", "t_count = 0", "t_count", "0", "s_count += 1", "s_count", "1", "t_count += 1", "t_count", "1", "last_char = char", "last_char", "char", "if last_char == \"T\":\n # Tで終わる場合\n if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count -= s_count\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n after_x += \"S\" * s_count\n else:\n # Sで終わる場合\n after_x += \"S\" * s_count\n# print(after_x)", "last_char == \"T\"", "last_char", "\"T\"", "if t_count >= s_count:\n # Sを全て使い切り、余ったTは確定で残る\n after_x += \"T\" * (t_count - s_count)\n t_count -= s_count\n s_count = 0\n else:\n # Tを全部使い切り、余ったSは引き継がれる\n s_count -= t_count\n t_count = 0\n after_x += \"S\" * s_count\n ", "t_count >= s_count", "t_count", "s_count", "after_x += \"T\" * (t_count - s_count)", "after_x", "\"T\" * (t_count - s_count)", "\"T\"", "t_count - s_count", "t_count", "s_count", "t_count -= s_count", "t_count", "s_count", "s_count = 0", "s_count", "0", "s_count -= t_count", "s_count", "t_count", "t_count = 0", "t_count", "0", "after_x += \"S\" * s_count", "after_x", "\"S\" * s_count", "\"S\"", "s_count", "after_x += \"S\" * s_count", "after_x", "\"S\" * s_count", "\"S\"", "s_count", "ans = len(after_x)", "ans", "len(after_x)", "len", "after_x", "print(ans)", "print", "ans", "t_count = 0", "0", "t_count", "X = input()", "input()", "X", "s_count += 1", "1", "s_count", "t_count = 0", "0", "t_count", "s_count = 0", "0", "s_count", "t_count = 0", "0", "t_count", "s_count += 1", "1", "s_count", "t_count -= s_count", "s_count", "t_count", "last_char = char", "char", "last_char", "after_x += \"S\" * s_count", "\"S\" * s_count", "after_x", "after_x += \"S\" * s_count", "\"S\" * s_count", "after_x", "s_count = 0", "0", "s_count", "s_count -= t_count", "t_count", "s_count", "N = len(X)", "len(X)", "N", "s_count, t_count = 0, 0", "0", "s_count", "t_count = 0, 0", "0", "t_count", "after_x = \"\"", "\"\"", "after_x", "next_i = 0", "0", "next_i", "after_x += x", "x", "after_x", "after_x += \"T\" * (t_count - s_count)", "\"T\" * (t_count - s_count)", "after_x", "next_i = i", "i", "next_i", "t_count += 1", "1", "t_count", "ans = len(after_x)", "len(after_x)", "ans", "s_count -= t_count", "t_count", "s_count", "after_x += \"T\" * (t_count - s_count)", "\"T\" * (t_count - s_count)", "after_x" ]
#!/usr/bin/env python3 X = input() N = len(X) after_x = "" next_i = 0 # 連続する箇所で部分文字列を作りたい s_count, t_count = 0, 0 if X[0] == "T": # Tから始まる場合、最初の連続するTは確定で残るので切り捨てる for i, x in enumerate(X): if x == "T": after_x += x else: break next_i = i if len(after_x) != N: # 「全ての文字列がT」ではない # 残りの文字列について操作する(最初のTは処理したので、必ずSから始まる) for i, char in enumerate(X[next_i:]): if i == 0: # 最初は確定でSから始まる s_count += 1 continue if char == "S": # Sの場合 if X[next_i + i - 1] == "T": # T->Sの切り替わりのとき if t_count >= s_count: # Sを全て使い切り、余ったTは確定で残る after_x += "T" * (t_count - s_count) t_count = 0 s_count = 0 else: # Tを全部使い切り、余ったSは引き継がれる s_count -= t_count t_count = 0 s_count += 1 else: # Tの場合 t_count += 1 last_char = char if last_char == "T": # Tで終わる場合 if t_count >= s_count: # Sを全て使い切り、余ったTは確定で残る after_x += "T" * (t_count - s_count) t_count -= s_count s_count = 0 else: # Tを全部使い切り、余ったSは引き継がれる s_count -= t_count t_count = 0 after_x += "S" * s_count else: # Sで終わる場合 after_x += "S" * s_count # print(after_x) ans = len(after_x) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 18, 13, 39, 17, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 13, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 18, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 50, 2 ], [ 47, 8 ], [ 51, 10 ], [ 59, 14 ], [ 53, 17 ], [ 48, 20 ], [ 51, 20 ], [ 23, 22 ], [ 48, 22 ], [ 51, 22 ], [ 22, 26 ], [ 56, 29 ], [ 22, 34 ], [ 60, 36 ], [ 66, 36 ], [ 57, 36 ], [ 65, 38 ], [ 62, 41 ], [ 63, 45 ], [ 54, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "x = list(input())\nx = x[::-1]\ncounter = 0\nans = len(x)\nfor i in x:\n if i == \"T\":\n counter += 1\n elif i == \"S\" and counter:\n counter -= 1\n ans -= 2\nprint(ans)", "x = list(input())", "x", "list(input())", "list", "input()", "input", "x = x[::-1]", "x", "x[::-1]", "x", "::-1", "-1", "counter = 0", "counter", "0", "ans = len(x)", "ans", "len(x)", "len", "x", "for i in x:\n if i == \"T\":\n counter += 1\n elif i == \"S\" and counter:\n counter -= 1\n ans -= 2", "i", "x", "if i == \"T\":\n counter += 1\n elif i == \"S\" and counter:\n counter -= 1\n ans -= 2", "i == \"T\"", "i", "\"T\"", "counter += 1", "counter", "1", "elif i == \"S\" and counter:\n counter -= 1\n ans -= 2", "i == \"S\" and counter", "i == \"S\"", "i", "\"S\"", "counter", "counter -= 1", "counter", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "x = x[::-1]", "x[::-1]", "x", "x = list(input())", "list(input())", "x", "ans = len(x)", "len(x)", "ans", "counter += 1", "1", "counter", "counter = 0", "0", "counter", "ans -= 2", "2", "ans", "counter -= 1", "1", "counter" ]
x = list(input()) x = x[::-1] counter = 0 ans = len(x) for i in x: if i == "T": counter += 1 elif i == "S" and counter: counter -= 1 ans -= 2 print(ans)
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 17, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 12, 11 ], [ 15, 14 ], [ 4, 14 ], [ 14, 18 ], [ 8, 22 ], [ 31, 22 ], [ 25, 22 ], [ 26, 25 ], [ 29, 28 ], [ 32, 31 ], [ 4, 38 ], [ 28, 41 ], [ 11, 41 ], [ 50, 47 ] ]
[ "def main():\n X = input()\n cnt_s = 0\n cnt_removal = 0\n for x in X:\n if x == 'T':\n if cnt_s > 0:\n cnt_s -= 1\n cnt_removal += 1\n else:\n cnt_s += 1\n print(len(X) - 2 * cnt_removal)\n\n\nif __name__ == '__main__':\n main()", "def main():\n X = input()\n cnt_s = 0\n cnt_removal = 0\n for x in X:\n if x == 'T':\n if cnt_s > 0:\n cnt_s -= 1\n cnt_removal += 1\n else:\n cnt_s += 1\n print(len(X) - 2 * cnt_removal)", "main", "X = input()", "X", "input()", "input", "cnt_s = 0", "cnt_s", "0", "cnt_removal = 0", "cnt_removal", "0", "for x in X:\n if x == 'T':\n if cnt_s > 0:\n cnt_s -= 1\n cnt_removal += 1\n else:\n cnt_s += 1\n ", "x", "X", "if x == 'T':\n if cnt_s > 0:\n cnt_s -= 1\n cnt_removal += 1\n else:\n cnt_s += 1\n ", "x == 'T'", "x", "'T'", "if cnt_s > 0:\n cnt_s -= 1\n cnt_removal += 1\n ", "cnt_s > 0", "cnt_s", "0", "cnt_s -= 1", "cnt_s", "1", "cnt_removal += 1", "cnt_removal", "1", "cnt_s += 1", "cnt_s", "1", "print(len(X) - 2 * cnt_removal)", "print", "len(X) - 2 * cnt_removal", "len(X)", "len", "X", "2 * cnt_removal", "2", "cnt_removal", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n X = input()\n cnt_s = 0\n cnt_removal = 0\n for x in X:\n if x == 'T':\n if cnt_s > 0:\n cnt_s -= 1\n cnt_removal += 1\n else:\n cnt_s += 1\n print(len(X) - 2 * cnt_removal)", "def main():\n X = input()\n cnt_s = 0\n cnt_removal = 0\n for x in X:\n if x == 'T':\n if cnt_s > 0:\n cnt_s -= 1\n cnt_removal += 1\n else:\n cnt_s += 1\n print(len(X) - 2 * cnt_removal)", "main" ]
def main(): X = input() cnt_s = 0 cnt_removal = 0 for x in X: if x == 'T': if cnt_s > 0: cnt_s -= 1 cnt_removal += 1 else: cnt_s += 1 print(len(X) - 2 * cnt_removal) if __name__ == '__main__': main()
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 15, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 13, 17, 14, 13, 14, 2, 4, 18, 13, 13, 17, 4, 18, 13, 13, 17, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 2, 13, 10, 39, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 89, 11 ], [ 80, 16 ], [ 92, 23 ], [ 86, 27 ], [ 93, 30 ], [ 83, 32 ], [ 36, 35 ], [ 93, 35 ], [ 35, 39 ], [ 84, 43 ], [ 35, 45 ], [ 35, 48 ], [ 84, 56 ], [ 84, 61 ], [ 84, 66 ], [ 35, 68 ], [ 84, 71 ], [ 35, 73 ], [ 84, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ] ]
[ "# input()\n# int(input())\n# map(int, input().split())\n# list(map(int, input().split()))\nimport math\nimport sys\nimport bisect\nimport heapq # 優先度付きキュー(最小値取り出し)\nfrom collections import deque\ninf = 10 ** 15\nmod = 10 ** 9 + 7\ns = input()\nn = len(s)\nstack = []\nfor c in s:\n if c == 'S':\n stack.append(c)\n if c == 'T':\n if stack:\n if stack.pop() == 'T':\n stack.append('T')\n stack.append(c)\n else:\n stack.append(c)\nprint(len(stack))", "import math", "math", "import sys", "sys", "import bisect", "bisect", "import heapq", "heapq", "from collections import deque", "inf = 10 ** 15", "inf", "10 ** 15", "10", "15", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "s = input()", "s", "input()", "input", "n = len(s)", "n", "len(s)", "len", "s", "stack = []", "stack", "[]", "for c in s:\n if c == 'S':\n stack.append(c)\n if c == 'T':\n if stack:\n if stack.pop() == 'T':\n stack.append('T')\n stack.append(c)\n else:\n stack.append(c)", "c", "s", "if c == 'S':\n stack.append(c)\n ", "c == 'S'", "c", "'S'", "stack.append(c)", "stack.append", "stack", "append", "c", "if c == 'T':\n if stack:\n if stack.pop() == 'T':\n stack.append('T')\n stack.append(c)\n else:\n stack.append(c)", "c == 'T'", "c", "'T'", "if stack:\n if stack.pop() == 'T':\n stack.append('T')\n stack.append(c)\n else:\n stack.append(c)", "stack", "if stack.pop() == 'T':\n stack.append('T')\n stack.append(c)\n ", "stack.pop() == 'T'", "stack.pop()", "stack.pop", "stack", "pop", "'T'", "stack.append('T')", "stack.append", "stack", "append", "'T'", "stack.append(c)", "stack.append", "stack", "append", "c", "stack.append(c)", "stack.append", "stack", "append", "c", "print(len(stack))", "print", "len(stack)", "len", "stack", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "stack = []", "[]", "stack", "n = len(s)", "len(s)", "n", "inf = 10 ** 15", "10 ** 15", "inf", "s = input()", "input()", "s" ]
# 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) stack = [] for c in s: if c == 'S': stack.append(c) if c == 'T': if stack: if stack.pop() == 'T': stack.append('T') stack.append(c) else: stack.append(c) print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 45, 2 ], [ 54, 6 ], [ 46, 9 ], [ 60, 11 ], [ 63, 14 ], [ 18, 17 ], [ 55, 20 ], [ 46, 24 ], [ 17, 25 ], [ 48, 28 ], [ 57, 31 ], [ 51, 34 ], [ 61, 37 ], [ 52, 37 ], [ 58, 38 ], [ 49, 38 ], [ 64, 38 ], [ 52, 42 ], [ 61, 42 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "S = input()\nN = len(S)\nans = 0\ncnt = 0\n\nfor i in range(N):\n if S[i] == 'T':\n cnt += 1\n else:\n cnt -= 1\n ans = max(ans,cnt)\n\nprint(ans * 2)", "S = input()", "S", "input()", "input", "N = len(S)", "N", "len(S)", "len", "S", "ans = 0", "ans", "0", "cnt = 0", "cnt", "0", "for i in range(N):\n if S[i] == 'T':\n cnt += 1\n else:\n cnt -= 1\n ans = max(ans,cnt)", "i", "range(N)", "range", "N", "if S[i] == 'T':\n cnt += 1\n else:\n cnt -= 1\n ", "S[i] == 'T'", "S[i]", "S", "i", "'T'", "cnt += 1", "cnt", "1", "cnt -= 1", "cnt", "1", "ans = max(ans,cnt)", "ans", "max(ans,cnt)", "max", "ans", "cnt", "print(ans * 2)", "print", "ans * 2", "ans", "2", "S = input()", "input()", "S", "cnt += 1", "1", "cnt", "ans = max(ans,cnt)", "max(ans,cnt)", "ans", "N = len(S)", "len(S)", "N", "cnt -= 1", "1", "cnt", "ans = 0", "0", "ans", "cnt = 0", "0", "cnt" ]
S = input() N = len(S) ans = 0 cnt = 0 for i in range(N): if S[i] == 'T': cnt += 1 else: cnt -= 1 ans = max(ans,cnt) print(ans * 2)