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, 17, 0, 13, 17, 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, 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 ], [ 50, 9 ], [ 53, 12 ], [ 56, 15 ], [ 19, 18 ], [ 45, 18 ], [ 18, 22 ], [ 57, 26 ], [ 48, 26 ], [ 60, 26 ], [ 62, 29 ], [ 59, 32 ], [ 47, 35 ], [ 63, 39 ], [ 54, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "x = input()\ns_cnt = 0\nt_cnt = 0\nans = 0\ntmp = 0\nfor s in x:\n if s == \"T\":\n if tmp == 0:\n ans += 2\n else:\n tmp -= 1\n else:\n tmp += 1\nprint(ans)", "x = input()", "x", "input()", "input", "s_cnt = 0", "s_cnt", "0", "t_cnt = 0", "t_cnt", "0", "ans = 0", "ans", "0", "tmp = 0", "tmp", "0", "for s in x:\n if s == \"T\":\n if tmp == 0:\n ans += 2\n else:\n tmp -= 1\n else:\n tmp += 1", "s", "x", "if s == \"T\":\n if tmp == 0:\n ans += 2\n else:\n tmp -= 1\n else:\n tmp += 1", "s == \"T\"", "s", "\"T\"", "if tmp == 0:\n ans += 2\n else:\n tmp -= 1\n ", "tmp == 0", "tmp", "0", "ans += 2", "ans", "2", "tmp -= 1", "tmp", "1", "tmp += 1", "tmp", "1", "print(ans)", "print", "ans", "s_cnt = 0", "0", "s_cnt", "x = input()", "input()", "x", "tmp += 1", "1", "tmp", "t_cnt = 0", "0", "t_cnt", "ans = 0", "0", "ans", "tmp = 0", "0", "tmp", "tmp -= 1", "1", "tmp", "ans += 2", "2", "ans" ]
x = input() s_cnt = 0 t_cnt = 0 ans = 0 tmp = 0 for s in x: if s == "T": if tmp == 0: ans += 2 else: tmp -= 1 else: tmp += 1 print(ans)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 17, 14, 2, 2, 4, 13, 13, 17, 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 ]
[ [ 50, 3 ], [ 53, 7 ], [ 13, 12 ], [ 51, 12 ], [ 12, 16 ], [ 54, 20 ], [ 54, 28 ], [ 54, 32 ], [ 54, 37 ], [ 54, 42 ], [ 54, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "#!/usr/bin/env python\n# coding: utf-8\n\n# In[18]:\n\n\nfrom collections import deque\n\n\n# In[12]:\n\n\nX = input()\n\n\n# In[26]:\n\n\nmylist = deque([])\nfor x in X:\n if x == \"S\":\n mylist.append(\"S\")\n else:\n if len(mylist) == 0 or mylist[-1] == \"T\":\n mylist.append(\"T\")\n else:\n mylist.pop()\nprint(len(mylist))\n\n\n# In[ ]:\n\n\n\n", "from collections import deque", "X = input()", "X", "input()", "input", "mylist = deque([])", "mylist", "deque([])", "deque", "[]", "for x in X:\n if x == \"S\":\n mylist.append(\"S\")\n else:\n if len(mylist) == 0 or mylist[-1] == \"T\":\n mylist.append(\"T\")\n else:\n mylist.pop()", "x", "X", "if x == \"S\":\n mylist.append(\"S\")\n else:\n if len(mylist) == 0 or mylist[-1] == \"T\":\n mylist.append(\"T\")\n else:\n mylist.pop()", "x == \"S\"", "x", "\"S\"", "mylist.append(\"S\")", "mylist.append", "mylist", "append", "\"S\"", "if len(mylist) == 0 or mylist[-1] == \"T\":\n mylist.append(\"T\")\n else:\n mylist.pop()", "len(mylist) == 0 or mylist[-1] == \"T\"", "len(mylist) == 0", "len(mylist)", "len", "mylist", "0", "mylist[-1] == \"T\"", "mylist[-1]", "mylist", "-1", "\"T\"", "mylist.append(\"T\")", "mylist.append", "mylist", "append", "\"T\"", "mylist.pop()", "mylist.pop", "mylist", "pop", "print(len(mylist))", "print", "len(mylist)", "len", "mylist", "X = input()", "input()", "X", "mylist = deque([])", "deque([])", "mylist" ]
#!/usr/bin/env python # coding: utf-8 # In[18]: from collections import deque # In[12]: X = input() # In[26]: mylist = deque([]) for x in X: if x == "S": mylist.append("S") else: if len(mylist) == 0 or mylist[-1] == "T": mylist.append("T") else: mylist.pop() print(len(mylist)) # In[ ]:
[ 7, 15, 13, 15, 0, 13, 4, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 39, 0, 13, 4, 13, 13, 42, 13, 0, 13, 4, 18, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 13, 9, 14, 2, 2, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 73, 5 ], [ 70, 18 ], [ 79, 21 ], [ 74, 24 ], [ 76, 28 ], [ 80, 31 ], [ 71, 37 ], [ 71, 41 ], [ 77, 43 ], [ 77, 48 ], [ 71, 52 ], [ 71, 57 ], [ 71, 61 ], [ 77, 63 ], [ 71, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ] ]
[ "import sys\nfrom collections import deque\n\nX = list(sys.stdin.readline().strip())\n\ns = []\nq = deque(X)\nwhile q:\n char = q.popleft()\n if len(s) == 0:\n s.append(char)\n continue\n \n if char == \"T\" and s[-1] == \"S\":\n s.pop()\n\n else:\n s.append(char)\n\nprint(len(s))", "import sys", "sys", "from collections import deque", "X = list(sys.stdin.readline().strip())", "X", "list(sys.stdin.readline().strip())", "list", "sys.stdin.readline().strip()", "sys.stdin.readline().strip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "strip", "s = []", "s", "[]", "q = deque(X)", "q", "deque(X)", "deque", "X", "while q:\n char = q.popleft()\n if len(s) == 0:\n s.append(char)\n continue\n \n if char == \"T\" and s[-1] == \"S\":\n s.pop()\n\n else:\n s.append(char)", "q", "char = q.popleft()", "char", "q.popleft()", "q.popleft", "q", "popleft", "if len(s) == 0:\n s.append(char)\n continue\n \n ", "len(s) == 0", "len(s)", "len", "s", "0", "s.append(char)", "s.append", "s", "append", "char", "continue", "if char == \"T\" and s[-1] == \"S\":\n s.pop()\n\n else:\n s.append(char)", "char == \"T\" and s[-1] == \"S\"", "char == \"T\"", "char", "\"T\"", "s[-1] == \"S\"", "s[-1]", "s", "-1", "\"S\"", "s.pop()", "s.pop", "s", "pop", "s.append(char)", "s.append", "s", "append", "char", "print(len(s))", "print", "len(s)", "len", "s", "s = []", "[]", "s", "X = list(sys.stdin.readline().strip())", "list(sys.stdin.readline().strip())", "X", "char = q.popleft()", "q.popleft()", "char", "q = deque(X)", "deque(X)", "q" ]
import sys from collections import deque X = list(sys.stdin.readline().strip()) s = [] q = deque(X) while q: char = q.popleft() if len(s) == 0: s.append(char) continue if char == "T" and s[-1] == "S": s.pop() else: s.append(char) print(len(s))
[ 7, 15, 13, 15, 15, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 4, 18, 13, 13, 2, 17, 17, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 18, 18, 13, 13, 13, 12, 13, 23, 13, 0, 13, 4, 13, 0, 13, 2, 39, 17, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 18, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 18, 13, 39, 17, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 4, 13, 2, 13, 13, 17, 0, 13, 2, 13, 17, 0, 13, 4, 13, 2, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 13, 4, 13, 13, 10, 2, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 17, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 17, 13, 10, 12, 13, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 34, 33 ], [ 47, 47 ], [ 154, 49 ], [ 149, 51 ], [ 169, 53 ], [ 155, 59 ], [ 166, 61 ], [ 184, 64 ], [ 172, 67 ], [ 181, 70 ], [ 155, 72 ], [ 182, 76 ], [ 157, 79 ], [ 151, 82 ], [ 86, 85 ], [ 155, 89 ], [ 182, 95 ], [ 164, 95 ], [ 85, 98 ], [ 160, 101 ], [ 158, 105 ], [ 185, 105 ], [ 194, 105 ], [ 191, 105 ], [ 152, 106 ], [ 167, 106 ], [ 176, 106 ], [ 179, 106 ], [ 145, 109 ], [ 161, 111 ], [ 178, 114 ], [ 152, 118 ], [ 167, 118 ], [ 176, 118 ], [ 179, 118 ], [ 158, 119 ], [ 185, 119 ], [ 194, 119 ], [ 191, 119 ], [ 190, 122 ], [ 85, 126 ], [ 193, 129 ], [ 85, 133 ], [ 175, 136 ], [ 163, 139 ], [ 85, 140 ], [ 146, 143 ], [ 173, 143 ], [ 145, 146 ], [ 151, 152 ], [ 154, 155 ], [ 157, 158 ], [ 160, 161 ], [ 85, 163 ], [ 163, 164 ], [ 166, 167 ], [ 169, 170 ], [ 172, 173 ], [ 175, 176 ], [ 178, 179 ], [ 181, 182 ], [ 184, 185 ], [ 190, 191 ], [ 193, 194 ] ]
[ "# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque\nfrom collections import defaultdict\nimport heapq\nimport collections\nimport itertools\nimport bisect\nimport copy\nimport math\nfrom itertools import accumulate\nsys.setrecursionlimit(10**6)\n\n# lis_of_lis = [[] for _ in range(N)]\n\n\ndef zz(): return list(map(int, sys.stdin.readline().split()))\n\n\ndef z(): return int(sys.stdin.readline())\n\n\ndef S(): return sys.stdin.readline()[:-1]\n\n\ndef C(line): return [sys.stdin.readline() for _ in range(line)]\n\n\nX = S()\nnum_S = [0] * len(X)\nt_count = 0\ns_count = 0\nans = 0\nprev = X[-1]\nif (prev == 'S'):\n s_count = 1\nelse:\n t_count = 1\nfor x in reversed(X[:-1]):\n if (prev == 'S' and x == 'T'):\n # リセット\n rest = max(s_count - t_count, 0)\n ans += (rest*2)\n t_count = max(t_count - s_count, 0)\n s_count = 0\n if (x == 'S'):\n s_count += 1\n if (x == 'T'):\n t_count += 1\n prev = x\nprint(ans)\n\n\n# for i, x in enumerate(X):\n# if(x == 'S'):\n# num_S[i] = 1\n\n# num_S = list(accumulate(num_S))\n# print(num_S)", "import sys", "sys", "from collections import deque", "from collections import defaultdict", "import heapq", "heapq", "import collections", "collections", "import itertools", "itertools", "import bisect", "bisect", "import copy", "copy", "import math", "math", "from itertools import accumulate", "sys.setrecursionlimit(10**6)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**6", "10", "6", "def zz(): return list(map(int, sys.stdin.readline().split()))", "zz", "def z(): return int(sys.stdin.readline())", "z", "def S(): return sys.stdin.readline()[:-1]", "S", "sys.stdin.readline() for _ in range(line)", "for _ in range(line)", "_", "range(line)", "range", "line", "for _ in range(line)", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def C(line): return [sys.stdin.readline() for _ in range(line)]", "C", "line", "line", "X = S()", "X", "S()", "S", "num_S = [0] * len(X)", "num_S", "[0] * len(X)", "[0]", "0", "len(X)", "len", "X", "t_count = 0", "t_count", "0", "s_count = 0", "s_count", "0", "ans = 0", "ans", "0", "prev = X[-1]", "prev", "X[-1]", "X", "-1", "if (prev == 'S'):\n s_count = 1\nelse:\n t_count = 1", "prev == 'S'", "prev", "'S'", "s_count = 1", "s_count", "1", "t_count = 1", "t_count", "1", "for x in reversed(X[:-1]):\n if (prev == 'S' and x == 'T'):\n # リセット\n rest = max(s_count - t_count, 0)\n ans += (rest*2)\n t_count = max(t_count - s_count, 0)\n s_count = 0\n if (x == 'S'):\n s_count += 1\n if (x == 'T'):\n t_count += 1\n prev = x", "x", "reversed(X[:-1])", "reversed", "X[:-1]", "X", ":-1", "-1", "if (prev == 'S' and x == 'T'):\n # リセット\n rest = max(s_count - t_count, 0)\n ans += (rest*2)\n t_count = max(t_count - s_count, 0)\n s_count = 0\n ", "prev == 'S' and x == 'T'", "prev == 'S'", "prev", "'S'", "x == 'T'", "x", "'T'", "rest = max(s_count - t_count, 0)", "rest", "max(s_count - t_count, 0)", "max", "s_count - t_count", "s_count", "t_count", "0", "ans += (rest*2)", "ans", "rest*2", "rest", "2", "t_count = max(t_count - s_count, 0)", "t_count", "max(t_count - s_count, 0)", "max", "t_count - s_count", "t_count", "s_count", "0", "s_count = 0", "s_count", "0", "if (x == 'S'):\n s_count += 1\n ", "x == 'S'", "x", "'S'", "s_count += 1", "s_count", "1", "if (x == 'T'):\n t_count += 1\n ", "x == 'T'", "x", "'T'", "t_count += 1", "t_count", "1", "prev = x", "prev", "x", "print(ans)", "print", "ans", "ans += (rest*2)", "rest*2", "ans", "def S(): return sys.stdin.readline()[:-1]", "def S(): return sys.stdin.readline()[:-1]", "S", "t_count = 1", "1", "t_count", "X = S()", "S()", "X", "s_count = 1", "1", "s_count", "rest = max(s_count - t_count, 0)", "max(s_count - t_count, 0)", "rest", "prev = x", "x", "prev", "t_count = 0", "0", "t_count", "num_S = [0] * len(X)", "[0] * len(X)", "num_S", "ans = 0", "0", "ans", "t_count += 1", "1", "t_count", "t_count = max(t_count - s_count, 0)", "max(t_count - s_count, 0)", "t_count", "prev = X[-1]", "X[-1]", "prev", "s_count = 0", "0", "s_count", "def z(): return int(sys.stdin.readline())", "def z(): return int(sys.stdin.readline())", "z", "s_count = 0", "0", "s_count", "s_count += 1", "1", "s_count", "def zz(): return list(map(int, sys.stdin.readline().split()))", "def zz(): return list(map(int, sys.stdin.readline().split()))", "zz", "def C(line): return [sys.stdin.readline() for _ in range(line)]", "def C(line): return [sys.stdin.readline() for _ in range(line)]", "C" ]
# -*- coding: utf-8 -*- import sys from collections import deque from collections import defaultdict import heapq import collections import itertools import bisect import copy import math from itertools import accumulate sys.setrecursionlimit(10**6) # lis_of_lis = [[] for _ in range(N)] def zz(): return list(map(int, sys.stdin.readline().split())) def z(): return int(sys.stdin.readline()) def S(): return sys.stdin.readline()[:-1] def C(line): return [sys.stdin.readline() for _ in range(line)] X = S() num_S = [0] * len(X) t_count = 0 s_count = 0 ans = 0 prev = X[-1] if (prev == 'S'): s_count = 1 else: t_count = 1 for x in reversed(X[:-1]): if (prev == 'S' and x == 'T'): # リセット rest = max(s_count - t_count, 0) ans += (rest*2) t_count = max(t_count - s_count, 0) s_count = 0 if (x == 'S'): s_count += 1 if (x == 'T'): t_count += 1 prev = x print(ans) # for i, x in enumerate(X): # if(x == 'S'): # num_S[i] = 1 # num_S = list(accumulate(num_S)) # print(num_S)
[ 7, 0, 13, 4, 13, 0, 13, 39, 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, 4, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 47, 2 ], [ 50, 6 ], [ 10, 9 ], [ 48, 9 ], [ 9, 13 ], [ 51, 17 ], [ 9, 19 ], [ 51, 25 ], [ 51, 29 ], [ 51, 34 ], [ 9, 36 ], [ 51, 39 ], [ 51, 45 ], [ 47, 48 ], [ 50, 51 ] ]
[ "X=input()\nq = []\nfor x in X:\n if x=='S':\n q.append(x)\n else:\n if len(q)==0 or q[-1]=='T':\n q.append(x)\n else:\n q.pop()\nprint(len(q))", "X=input()", "X", "input()", "input", "q = []", "q", "[]", "for x in X:\n if x=='S':\n q.append(x)\n else:\n if len(q)==0 or q[-1]=='T':\n q.append(x)\n else:\n q.pop()", "x", "X", "if x=='S':\n q.append(x)\n else:\n if len(q)==0 or q[-1]=='T':\n q.append(x)\n else:\n q.pop()", "x=='S'", "x", "'S'", "q.append(x)", "q.append", "q", "append", "x", "if len(q)==0 or q[-1]=='T':\n q.append(x)\n else:\n q.pop()", "len(q)==0 or q[-1]=='T'", "len(q)==0", "len(q)", "len", "q", "0", "q[-1]=='T'", "q[-1]", "q", "-1", "'T'", "q.append(x)", "q.append", "q", "append", "x", "q.pop()", "q.pop", "q", "pop", "print(len(q))", "print", "len(q)", "len", "q", "X=input()", "input()", "X", "q = []", "[]", "q" ]
X=input() q = [] for x in X: if x=='S': q.append(x) else: if len(q)==0 or q[-1]=='T': q.append(x) else: q.pop() print(len(q))
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 17, 28, 13, 4, 13, 13, 4, 18, 13, 13, 18, 13, 13, 14, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 0, 13, 4, 18, 13, 13, 14, 2, 40, 13, 17, 40, 13, 17, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 85, 3 ], [ 88, 7 ], [ 86, 10 ], [ 91, 12 ], [ 79, 15 ], [ 82, 18 ], [ 94, 21 ], [ 27, 26 ], [ 89, 29 ], [ 95, 32 ], [ 86, 35 ], [ 26, 36 ], [ 95, 41 ], [ 97, 44 ], [ 95, 47 ], [ 100, 50 ], [ 95, 53 ], [ 101, 58 ], [ 98, 61 ], [ 95, 65 ], [ 101, 67 ], [ 95, 70 ], [ 98, 72 ], [ 95, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ], [ 100, 101 ] ]
[ "from collections import deque\nX=input()\nN=len(X)\ncnt=0\nsptm=0\nans=0\nd=deque()\n\"\"\"\nfor i in range(N):\n if X[i]==\"S\":\n sptm=sptm+1\n if X[i]==\"T\":\n sptm=sptm-1\n if sptm<0:\n ans=ans+1\n sptm=0\n #print(sptm,ans)\nprint(ans+max(0,sptm))\n\"\"\"\nfor i in range(N):\n d.append(X[i])\n if len(d)>1:\n s1=d.pop()\n s2=d.pop()\n if (s2!=\"S\")or(s1!=\"T\"):\n d.append(s2)\n d.append(s1)\n #print(d)\nprint(len(d))", "from collections import deque", "X=input()", "X", "input()", "input", "N=len(X)", "N", "len(X)", "len", "X", "cnt=0", "cnt", "0", "sptm=0", "sptm", "0", "ans=0", "ans", "0", "d=deque()", "d", "deque()", "deque", "\"\"\"\nfor i in range(N):\n if X[i]==\"S\":\n sptm=sptm+1\n if X[i]==\"T\":\n sptm=sptm-1\n if sptm<0:\n ans=ans+1\n sptm=0\n #print(sptm,ans)\nprint(ans+max(0,sptm))\n\"\"\"", "for i in range(N):\n d.append(X[i])\n if len(d)>1:\n s1=d.pop()\n s2=d.pop()\n if (s2!=\"S\")or(s1!=\"T\"):\n d.append(s2)\n d.append(s1)\n #print(d)", "i", "range(N)", "range", "N", "d.append(X[i])", "d.append", "d", "append", "X[i]", "X", "i", "if len(d)>1:\n s1=d.pop()\n s2=d.pop()\n if (s2!=\"S\")or(s1!=\"T\"):\n d.append(s2)\n d.append(s1)\n #print(d)", "len(d)>1", "len(d)", "len", "d", "1", "s1=d.pop()", "s1", "d.pop()", "d.pop", "d", "pop", "s2=d.pop()", "s2", "d.pop()", "d.pop", "d", "pop", "if (s2!=\"S\")or(s1!=\"T\"):\n d.append(s2)\n d.append(s1)\n #print(d)", "(s2!=\"S\")or(s1!=\"T\")", "s2!=\"S\"", "s2", "\"S\"", "s1!=\"T\"", "s1", "\"T\"", "d.append(s2)", "d.append", "d", "append", "s2", "d.append(s1)", "d.append", "d", "append", "s1", "print(len(d))", "print", "len(d)", "len", "d", "sptm=0", "0", "sptm", "ans=0", "0", "ans", "X=input()", "input()", "X", "N=len(X)", "len(X)", "N", "cnt=0", "0", "cnt", "d=deque()", "deque()", "d", "s1=d.pop()", "d.pop()", "s1", "s2=d.pop()", "d.pop()", "s2" ]
from collections import deque X=input() N=len(X) cnt=0 sptm=0 ans=0 d=deque() """ for i in range(N): if X[i]=="S": sptm=sptm+1 if X[i]=="T": sptm=sptm-1 if sptm<0: ans=ans+1 sptm=0 #print(sptm,ans) print(ans+max(0,sptm)) """ for i in range(N): d.append(X[i]) if len(d)>1: s1=d.pop() s2=d.pop() if (s2!="S")or(s1!="T"): d.append(s2) d.append(s1) #print(d) print(len(d))
[ 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 43, 2 ], [ 46, 6 ], [ 49, 9 ], [ 13, 12 ], [ 44, 12 ], [ 12, 16 ], [ 52, 19 ], [ 47, 23 ], [ 38, 23 ], [ 53, 23 ], [ 37, 26 ], [ 40, 29 ], [ 41, 34 ], [ 50, 34 ], [ 38, 35 ], [ 53, 35 ], [ 47, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "S = input()\ns_cnt =0\nt_cnt =0\n\nfor s in S:\n if s == 'S':\n s_cnt += 1\n else:\n if s_cnt >0:\n s_cnt -= 1\n else:\n t_cnt += 1\n \nprint(t_cnt + s_cnt)", "S = input()", "S", "input()", "input", "s_cnt =0", "s_cnt", "0", "t_cnt =0", "t_cnt", "0", "for s in S:\n if s == 'S':\n s_cnt += 1\n else:\n if s_cnt >0:\n s_cnt -= 1\n else:\n t_cnt += 1\n ", "s", "S", "if s == 'S':\n s_cnt += 1\n else:\n if s_cnt >0:\n s_cnt -= 1\n else:\n t_cnt += 1\n ", "s == 'S'", "s", "'S'", "s_cnt += 1", "s_cnt", "1", "if s_cnt >0:\n s_cnt -= 1\n else:\n t_cnt += 1\n ", "s_cnt >0", "s_cnt", "0", "s_cnt -= 1", "s_cnt", "1", "t_cnt += 1", "t_cnt", "1", "print(t_cnt + s_cnt)", "print", "t_cnt + s_cnt", "t_cnt", "s_cnt", "s_cnt -= 1", "1", "s_cnt", "t_cnt += 1", "1", "t_cnt", "S = input()", "input()", "S", "s_cnt =0", "0", "s_cnt", "t_cnt =0", "0", "t_cnt", "s_cnt += 1", "1", "s_cnt" ]
S = input() s_cnt =0 t_cnt =0 for s in S: if s == 'S': s_cnt += 1 else: if s_cnt >0: s_cnt -= 1 else: t_cnt += 1 print(t_cnt + s_cnt)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 2, 13, 39, 40, 18, 13, 17, 17, 4, 18, 13, 13, 18, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 61, 2 ], [ 64, 6 ], [ 62, 9 ], [ 58, 11 ], [ 15, 14 ], [ 65, 17 ], [ 62, 21 ], [ 14, 22 ], [ 59, 26 ], [ 62, 29 ], [ 14, 30 ], [ 59, 34 ], [ 59, 38 ], [ 59, 43 ], [ 62, 46 ], [ 14, 47 ], [ 59, 50 ], [ 59, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "s = input()\nn = len(s)\nans = []\nfor i in range(n):\n if s[i] == \"S\":\n ans.append(s[i])\n else:\n if ans == [] or ans[-1] != \"S\":\n ans.append(s[i])\n else:\n ans.pop()\nprint(len(ans))", "s = input()", "s", "input()", "input", "n = len(s)", "n", "len(s)", "len", "s", "ans = []", "ans", "[]", "for i in range(n):\n if s[i] == \"S\":\n ans.append(s[i])\n else:\n if ans == [] or ans[-1] != \"S\":\n ans.append(s[i])\n else:\n ans.pop()", "i", "range(n)", "range", "n", "if s[i] == \"S\":\n ans.append(s[i])\n else:\n if ans == [] or ans[-1] != \"S\":\n ans.append(s[i])\n else:\n ans.pop()", "s[i] == \"S\"", "s[i]", "s", "i", "\"S\"", "ans.append(s[i])", "ans.append", "ans", "append", "s[i]", "s", "i", "if ans == [] or ans[-1] != \"S\":\n ans.append(s[i])\n else:\n ans.pop()", "ans == [] or ans[-1] != \"S\"", "ans == []", "ans", "[]", "ans[-1] != \"S\"", "ans[-1]", "ans", "-1", "\"S\"", "ans.append(s[i])", "ans.append", "ans", "append", "s[i]", "s", "i", "ans.pop()", "ans.pop", "ans", "pop", "print(len(ans))", "print", "len(ans)", "len", "ans", "ans = []", "[]", "ans", "s = input()", "input()", "s", "n = len(s)", "len(s)", "n" ]
s = input() n = len(s) ans = [] for i in range(n): if s[i] == "S": ans.append(s[i]) else: if ans == [] or ans[-1] != "S": ans.append(s[i]) else: ans.pop() print(len(ans))
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 13, 4, 18, 13, 13, 13, 42, 40, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 0, 13, 4, 18, 13, 13, 14, 2, 2, 13, 17, 2, 13, 17, 9, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 3, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 71, 3 ], [ 65, 7 ], [ 12, 11 ], [ 66, 11 ], [ 72, 15 ], [ 11, 17 ], [ 72, 22 ], [ 68, 25 ], [ 72, 28 ], [ 62, 31 ], [ 72, 34 ], [ 63, 39 ], [ 69, 42 ], [ 72, 47 ], [ 63, 49 ], [ 72, 52 ], [ 69, 54 ], [ 72, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "from collections import deque\nd = deque()\nX = input()\nfor c in X:\n d.append(c)\n while len(d) >= 2:\n new = d.pop()\n last = d.pop()\n if last == \"S\" and new == \"T\":\n continue\n else:\n d.append(last)\n d.append(new)\n break\nprint(len(d))", "from collections import deque", "d = deque()", "d", "deque()", "deque", "X = input()", "X", "input()", "input", "for c in X:\n d.append(c)\n while len(d) >= 2:\n new = d.pop()\n last = d.pop()\n if last == \"S\" and new == \"T\":\n continue\n else:\n d.append(last)\n d.append(new)\n break", "c", "X", "d.append(c)", "d.append", "d", "append", "c", "while len(d) >= 2:\n new = d.pop()\n last = d.pop()\n if last == \"S\" and new == \"T\":\n continue\n else:\n d.append(last)\n d.append(new)\n break", "len(d) >= 2", "len(d)", "len", "d", "2", "new = d.pop()", "new", "d.pop()", "d.pop", "d", "pop", "last = d.pop()", "last", "d.pop()", "d.pop", "d", "pop", "if last == \"S\" and new == \"T\":\n continue\n else:\n d.append(last)\n d.append(new)\n break", "last == \"S\" and new == \"T\"", "last == \"S\"", "last", "\"S\"", "new == \"T\"", "new", "\"T\"", "continue", "d.append(last)", "d.append", "d", "append", "last", "d.append(new)", "d.append", "d", "append", "new", "break", "print(len(d))", "print", "len(d)", "len", "d", "last = d.pop()", "d.pop()", "last", "X = input()", "input()", "X", "new = d.pop()", "d.pop()", "new", "d = deque()", "deque()", "d" ]
from collections import deque d = deque() X = input() for c in X: d.append(c) while len(d) >= 2: new = d.pop() last = d.pop() if last == "S" and new == "T": continue else: d.append(last) d.append(new) break print(len(d))
[ 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 43, 2 ], [ 40, 6 ], [ 52, 9 ], [ 13, 12 ], [ 44, 12 ], [ 12, 16 ], [ 49, 19 ], [ 53, 23 ], [ 38, 23 ], [ 50, 23 ], [ 46, 26 ], [ 37, 29 ], [ 47, 34 ], [ 41, 34 ], [ 38, 35 ], [ 50, 35 ], [ 53, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "S = input()\n\nt = 0\nstock = 0\nfor c in S:\n if c == \"S\":\n stock += 1\n elif stock == 0:\n t += 1\n else:\n stock -= 1\nprint(t + stock)\n", "S = input()", "S", "input()", "input", "t = 0", "t", "0", "stock = 0", "stock", "0", "for c in S:\n if c == \"S\":\n stock += 1\n elif stock == 0:\n t += 1\n else:\n stock -= 1", "c", "S", "if c == \"S\":\n stock += 1\n elif stock == 0:\n t += 1\n else:\n stock -= 1", "c == \"S\"", "c", "\"S\"", "stock += 1", "stock", "1", "elif stock == 0:\n t += 1\n ", "stock == 0", "stock", "0", "t += 1", "t", "1", "stock -= 1", "stock", "1", "print(t + stock)", "print", "t + stock", "t", "stock", "stock -= 1", "1", "stock", "t = 0", "0", "t", "S = input()", "input()", "S", "t += 1", "1", "t", "stock += 1", "1", "stock", "stock = 0", "0", "stock" ]
S = input() t = 0 stock = 0 for c in S: if c == "S": stock += 1 elif stock == 0: t += 1 else: stock -= 1 print(t + stock)
[ 7, 0, 13, 39, 28, 13, 4, 13, 14, 2, 13, 17, 0, 13, 13, 14, 13, 14, 2, 2, 13, 17, 2, 18, 13, 17, 17, 0, 13, 13, 14, 2, 2, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 14, 2, 2, 13, 17, 2, 4, 13, 13, 17, 0, 13, 13, 4, 13, 4, 13, 13, 10, 13, 13, 10, 13, 13, 10, 13, 13, 10, 39, 13 ]
[ [ 73, 2 ], [ 6, 5 ], [ 5, 10 ], [ 70, 13 ], [ 5, 14 ], [ 5, 20 ], [ 71, 24 ], [ 74, 24 ], [ 65, 24 ], [ 68, 24 ], [ 67, 28 ], [ 5, 29 ], [ 5, 33 ], [ 68, 37 ], [ 71, 37 ], [ 74, 37 ], [ 65, 37 ], [ 68, 42 ], [ 71, 42 ], [ 74, 42 ], [ 65, 42 ], [ 5, 48 ], [ 71, 53 ], [ 74, 53 ], [ 65, 53 ], [ 68, 53 ], [ 64, 56 ], [ 5, 57 ], [ 65, 62 ], [ 68, 62 ], [ 71, 62 ], [ 74, 62 ], [ 5, 64 ], [ 64, 65 ], [ 5, 67 ], [ 67, 68 ], [ 5, 70 ], [ 70, 71 ], [ 73, 74 ] ]
[ "a=[]\nfor i in input():\n if i==\"S\":\n a+=i\n \n if a:\n if i==\"T\" and a[-1]==\"T\":\n a+=i\n if i==\"T\" and a[-1]==\"S\":\n a.pop(-1)\n elif i==\"T\" and len(a)==0:\n a+=i \nprint(len(a))", "a=[]", "a", "[]", "for i in input():\n if i==\"S\":\n a+=i\n \n if a:\n if i==\"T\" and a[-1]==\"T\":\n a+=i\n if i==\"T\" and a[-1]==\"S\":\n a.pop(-1)\n elif i==\"T\" and len(a)==0:\n a+=i ", "i", "input()", "input", "if i==\"S\":\n a+=i\n \n ", "i==\"S\"", "i", "\"S\"", "a+=i", "a", "i", "if a:\n if i==\"T\" and a[-1]==\"T\":\n a+=i\n if i==\"T\" and a[-1]==\"S\":\n a.pop(-1)\n elif i==\"T\" and len(a)==0:\n a+=i ", "a", "if i==\"T\" and a[-1]==\"T\":\n a+=i\n ", "i==\"T\" and a[-1]==\"T\"", "i==\"T\"", "i", "\"T\"", "a[-1]==\"T\"", "a[-1]", "a", "-1", "\"T\"", "a+=i", "a", "i", "if i==\"T\" and a[-1]==\"S\":\n a.pop(-1)\n ", "i==\"T\" and a[-1]==\"S\"", "i==\"T\"", "i", "\"T\"", "a[-1]==\"S\"", "a[-1]", "a", "-1", "\"S\"", "a.pop(-1)", "a.pop", "a", "pop", "-1", "elif i==\"T\" and len(a)==0:\n a+=i ", "i==\"T\" and len(a)==0", "i==\"T\"", "i", "\"T\"", "len(a)==0", "len(a)", "len", "a", "0", "a+=i", "a", "i", "print(len(a))", "print", "len(a)", "len", "a", "a+=i", "i", "a", "a+=i", "i", "a", "a+=i", "i", "a", "a=[]", "[]", "a" ]
a=[] for i in input(): if i=="S": a+=i if a: if i=="T" and a[-1]=="T": a+=i if i=="T" and a[-1]=="S": a.pop(-1) elif i=="T" and len(a)==0: a+=i print(len(a))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 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, 14, 2, 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, 10, 17, 13, 10, 17, 13 ]
[ [ 52, 2 ], [ 61, 6 ], [ 53, 9 ], [ 55, 11 ], [ 49, 14 ], [ 18, 17 ], [ 53, 22 ], [ 53, 26 ], [ 17, 27 ], [ 58, 30 ], [ 67, 33 ], [ 68, 37 ], [ 56, 37 ], [ 65, 37 ], [ 59, 37 ], [ 64, 40 ], [ 70, 43 ], [ 71, 47 ], [ 62, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "x = input()\n\nans = len(x)\nl = 0\nr = 0\nfor i in range(len(x)):\n if x[i] == \"S\":\n l += 1\n else:\n l -= 1\n\n if l < 0:\n l = 0\n else:\n ans -= 2\n\nprint(ans)", "x = input()", "x", "input()", "input", "ans = len(x)", "ans", "len(x)", "len", "x", "l = 0", "l", "0", "r = 0", "r", "0", "for i in range(len(x)):\n if x[i] == \"S\":\n l += 1\n else:\n l -= 1\n\n if l < 0:\n l = 0\n else:\n ans -= 2", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == \"S\":\n l += 1\n else:\n l -= 1\n\n if l < 0:\n l = 0\n else:\n ans -= 2", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "l += 1", "l", "1", "l -= 1", "l", "1", "if l < 0:\n l = 0\n else:\n ans -= 2", "l < 0", "l", "0", "l = 0", "l", "0", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "r = 0", "0", "r", "x = input()", "input()", "x", "l = 0", "0", "l", "l += 1", "1", "l", "ans = len(x)", "len(x)", "ans", "l = 0", "0", "l", "l -= 1", "1", "l", "ans -= 2", "2", "ans" ]
x = input() ans = len(x) l = 0 r = 0 for i in range(len(x)): if x[i] == "S": l += 1 else: l -= 1 if l < 0: l = 0 else: ans -= 2 print(ans)
[ 7, 15, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 42, 13, 4, 18, 13, 13, 4, 18, 13, 13, 14, 40, 13, 3, 42, 2, 2, 2, 13, 13, 2, 18, 13, 17, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 56, 3 ], [ 59, 9 ], [ 60, 16 ], [ 57, 20 ], [ 57, 24 ], [ 60, 30 ], [ 57, 31 ], [ 60, 34 ], [ 57, 39 ], [ 60, 44 ], [ 57, 48 ], [ 60, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "from collections import deque\nright = deque(input())\nleft = deque()\nwhile right:\n left.append(right.popleft())\n if not right:\n break\n while left and right and left[-1] == 'S' and right[0] == 'T':\n left.pop()\n right.popleft()\nprint(len(left))", "from collections import deque", "right = deque(input())", "right", "deque(input())", "deque", "input()", "input", "left = deque()", "left", "deque()", "deque", "while right:\n left.append(right.popleft())\n if not right:\n break\n while left and right and left[-1] == 'S' and right[0] == 'T':\n left.pop()\n right.popleft()", "right", "left.append(right.popleft())", "left.append", "left", "append", "right.popleft()", "right.popleft", "right", "popleft", "if not right:\n break\n ", "not right", "right", "break", "while left and right and left[-1] == 'S' and right[0] == 'T':\n left.pop()\n right.popleft()", "left and right and left[-1] == 'S' and right[0] == 'T'", "left and right and left[-1] == 'S'", "left and right", "left", "right", "left[-1] == 'S'", "left[-1]", "left", "-1", "'S'", "right[0] == 'T'", "right[0]", "right", "0", "'T'", "left.pop()", "left.pop", "left", "pop", "right.popleft()", "right.popleft", "right", "popleft", "print(len(left))", "print", "len(left)", "len", "left", "right = deque(input())", "deque(input())", "right", "left = deque()", "deque()", "left" ]
from collections import deque right = deque(input()) left = deque() while right: left.append(right.popleft()) if not right: break while left and right and left[-1] == 'S' and right[0] == 'T': left.pop() right.popleft() print(len(left))
[ 7, 0, 13, 4, 13, 4, 13, 15, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 14, 2, 13, 4, 13, 4, 18, 13, 13, 17, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 55, 2 ], [ 58, 9 ], [ 14, 13 ], [ 56, 13 ], [ 13, 17 ], [ 59, 21 ], [ 59, 26 ], [ 59, 32 ], [ 59, 37 ], [ 59, 42 ], [ 59, 46 ], [ 59, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "A=list(input())\nfrom collections import deque\nque=deque()\nfor i in A:\n if i==\"T\":\n if que==deque():\n que.append(\"T\")\n elif que[-1]==\"T\":\n que.append(\"T\")\n else:\n que.pop()\n else:\n que.append(\"S\")\nprint(len(que))", "A=list(input())", "A", "list(input())", "list", "input()", "input", "from collections import deque", "que=deque()", "que", "deque()", "deque", "for i in A:\n if i==\"T\":\n if que==deque():\n que.append(\"T\")\n elif que[-1]==\"T\":\n que.append(\"T\")\n else:\n que.pop()\n else:\n que.append(\"S\")", "i", "A", "if i==\"T\":\n if que==deque():\n que.append(\"T\")\n elif que[-1]==\"T\":\n que.append(\"T\")\n else:\n que.pop()\n else:\n que.append(\"S\")", "i==\"T\"", "i", "\"T\"", "if que==deque():\n que.append(\"T\")\n elif que[-1]==\"T\":\n que.append(\"T\")\n else:\n que.pop()\n ", "que==deque()", "que", "deque()", "deque", "que.append(\"T\")", "que.append", "que", "append", "\"T\"", "elif que[-1]==\"T\":\n que.append(\"T\")\n ", "que[-1]==\"T\"", "que[-1]", "que", "-1", "\"T\"", "que.append(\"T\")", "que.append", "que", "append", "\"T\"", "que.pop()", "que.pop", "que", "pop", "que.append(\"S\")", "que.append", "que", "append", "\"S\"", "print(len(que))", "print", "len(que)", "len", "que", "A=list(input())", "list(input())", "A", "que=deque()", "deque()", "que" ]
A=list(input()) from collections import deque que=deque() for i in A: if i=="T": if que==deque(): que.append("T") elif que[-1]=="T": que.append("T") else: que.pop() else: que.append("S") print(len(que))
[ 7, 12, 13, 15, 15, 15, 15, 15, 4, 13, 2, 17, 17, 0, 13, 8, 2, 17, 13, 12, 4, 13, 31, 13, 23, 12, 17, 23, 0, 13, 12, 4, 18, 4, 18, 13, 13, 13, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 4, 13, 0, 13, 2, 2, 17, 17, 17, 0, 13, 2, 2, 17, 17, 17, 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, 4, 13, 10, 12, 13 ]
[ [ 15, 14 ], [ 30, 29 ], [ 40, 39 ], [ 29, 49 ], [ 53, 52 ], [ 29, 57 ], [ 60, 59 ], [ 67, 66 ], [ 74, 73 ], [ 29, 75 ], [ 78, 77 ], [ 81, 80 ], [ 73, 83 ], [ 86, 85 ], [ 73, 85 ], [ 85, 89 ], [ 93, 92 ], [ 77, 96 ], [ 99, 96 ], [ 92, 96 ], [ 100, 99 ], [ 103, 102 ], [ 102, 106 ], [ 80, 106 ], [ 111, 108 ] ]
[ "def main():\n from sys import setrecursionlimit, stdin\n from os import environ\n from collections import defaultdict, deque, Counter\n from math import ceil, floor\n from itertools import accumulate, combinations, combinations_with_replacement\n setrecursionlimit(10**6)\n dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0\n input = lambda: stdin.readline().rstrip()\n LMIIS = lambda: list(map(int,input().split()))\n II = lambda: int(input())\n P = 10**9+7\n INF = 10**9+10\n\n S = input()\n num_s = 0\n ans = len(S)\n for c in S:\n if c == 'S':\n num_s += 1\n else:\n if num_s > 0:\n num_s -= 1\n ans -= 2\n print(ans)\n\n \nmain()", "def main():\n from sys import setrecursionlimit, stdin\n from os import environ\n from collections import defaultdict, deque, Counter\n from math import ceil, floor\n from itertools import accumulate, combinations, combinations_with_replacement\n setrecursionlimit(10**6)\n dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0\n input = lambda: stdin.readline().rstrip()\n LMIIS = lambda: list(map(int,input().split()))\n II = lambda: int(input())\n P = 10**9+7\n INF = 10**9+10\n\n S = input()\n num_s = 0\n ans = len(S)\n for c in S:\n if c == 'S':\n num_s += 1\n else:\n if num_s > 0:\n num_s -= 1\n ans -= 2\n print(ans)\n\n ", "main", "from sys import setrecursionlimit, stdin", "from os import environ", "from collections import defaultdict, deque, Counter", "from math import ceil, floor", "from itertools import accumulate, combinations, combinations_with_replacement", "setrecursionlimit(10**6)", "setrecursionlimit", "10**6", "10", "6", "dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0", "dbg", "(lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0", "'TERM_PROGRAM' in environ", "'TERM_PROGRAM'", "environ", "lambda *something: print(*something)", "print(*something)", "print", "*something", "something", "*something", "lambda *x: 0", "0", "*x", "input = lambda: stdin.readline().rstrip()", "input", "lambda: stdin.readline().rstrip()", "stdin.readline().rstrip()", "stdin.readline().rstrip", "stdin.readline()", "stdin.readline", "stdin", "readline", "rstrip", "LMIIS = lambda: list(map(int,input().split()))", "LMIIS", "lambda: list(map(int,input().split()))", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "II = lambda: int(input())", "II", "lambda: int(input())", "int(input())", "int", "input()", "input", "P = 10**9+7", "P", "10**9+7", "10**9", "10", "9", "7", "INF = 10**9+10", "INF", "10**9+10", "10**9", "10", "9", "10", "S = input()", "S", "input()", "input", "num_s = 0", "num_s", "0", "ans = len(S)", "ans", "len(S)", "len", "S", "for c in S:\n if c == 'S':\n num_s += 1\n else:\n if num_s > 0:\n num_s -= 1\n ans -= 2\n ", "c", "S", "if c == 'S':\n num_s += 1\n else:\n if num_s > 0:\n num_s -= 1\n ans -= 2\n ", "c == 'S'", "c", "'S'", "num_s += 1", "num_s", "1", "if num_s > 0:\n num_s -= 1\n ans -= 2\n ", "num_s > 0", "num_s", "0", "num_s -= 1", "num_s", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "main()", "main", "def main():\n from sys import setrecursionlimit, stdin\n from os import environ\n from collections import defaultdict, deque, Counter\n from math import ceil, floor\n from itertools import accumulate, combinations, combinations_with_replacement\n setrecursionlimit(10**6)\n dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0\n input = lambda: stdin.readline().rstrip()\n LMIIS = lambda: list(map(int,input().split()))\n II = lambda: int(input())\n P = 10**9+7\n INF = 10**9+10\n\n S = input()\n num_s = 0\n ans = len(S)\n for c in S:\n if c == 'S':\n num_s += 1\n else:\n if num_s > 0:\n num_s -= 1\n ans -= 2\n print(ans)\n\n ", "def main():\n from sys import setrecursionlimit, stdin\n from os import environ\n from collections import defaultdict, deque, Counter\n from math import ceil, floor\n from itertools import accumulate, combinations, combinations_with_replacement\n setrecursionlimit(10**6)\n dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0\n input = lambda: stdin.readline().rstrip()\n LMIIS = lambda: list(map(int,input().split()))\n II = lambda: int(input())\n P = 10**9+7\n INF = 10**9+10\n\n S = input()\n num_s = 0\n ans = len(S)\n for c in S:\n if c == 'S':\n num_s += 1\n else:\n if num_s > 0:\n num_s -= 1\n ans -= 2\n print(ans)\n\n ", "main" ]
def main(): from sys import setrecursionlimit, stdin from os import environ from collections import defaultdict, deque, Counter from math import ceil, floor from itertools import accumulate, combinations, combinations_with_replacement setrecursionlimit(10**6) dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in environ else lambda *x: 0 input = lambda: stdin.readline().rstrip() LMIIS = lambda: list(map(int,input().split())) II = lambda: int(input()) P = 10**9+7 INF = 10**9+10 S = input() num_s = 0 ans = len(S) for c in S: if c == 'S': num_s += 1 else: if num_s > 0: num_s -= 1 ans -= 2 print(ans) main()
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 42, 2, 13, 4, 13, 13, 14, 2, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 14, 2, 18, 13, 13, 17, 14, 40, 13, 13, 0, 13, 2, 13, 13, 0, 13, 17, 0, 13, 2, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 2, 4, 13, 13, 17, 14, 40, 13, 13, 0, 13, 2, 13, 13, 0, 13, 17, 0, 13, 2, 13, 13, 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, 2, 13, 10, 17, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 2, 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, 17, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 197, 2 ], [ 209, 6 ], [ 164, 9 ], [ 155, 12 ], [ 179, 15 ], [ 227, 18 ], [ 200, 21 ], [ 194, 24 ], [ 165, 28 ], [ 216, 28 ], [ 198, 31 ], [ 156, 34 ], [ 186, 34 ], [ 177, 34 ], [ 204, 34 ], [ 222, 34 ], [ 198, 39 ], [ 165, 40 ], [ 216, 40 ], [ 206, 43 ], [ 221, 46 ], [ 152, 49 ], [ 203, 52 ], [ 156, 56 ], [ 186, 56 ], [ 177, 56 ], [ 204, 56 ], [ 222, 56 ], [ 198, 61 ], [ 165, 62 ], [ 216, 62 ], [ 233, 65 ], [ 212, 68 ], [ 176, 71 ], [ 156, 75 ], [ 186, 75 ], [ 177, 75 ], [ 204, 75 ], [ 222, 75 ], [ 198, 80 ], [ 165, 81 ], [ 216, 81 ], [ 180, 85 ], [ 171, 85 ], [ 231, 85 ], [ 162, 85 ], [ 189, 85 ], [ 234, 85 ], [ 207, 85 ], [ 228, 86 ], [ 192, 86 ], [ 183, 86 ], [ 159, 86 ], [ 225, 86 ], [ 213, 86 ], [ 153, 86 ], [ 188, 88 ], [ 180, 90 ], [ 171, 90 ], [ 231, 90 ], [ 162, 90 ], [ 189, 90 ], [ 234, 90 ], [ 207, 90 ], [ 228, 91 ], [ 192, 91 ], [ 183, 91 ], [ 159, 91 ], [ 225, 91 ], [ 213, 91 ], [ 153, 91 ], [ 224, 93 ], [ 173, 96 ], [ 228, 98 ], [ 192, 98 ], [ 183, 98 ], [ 159, 98 ], [ 225, 98 ], [ 213, 98 ], [ 153, 98 ], [ 180, 99 ], [ 171, 99 ], [ 231, 99 ], [ 162, 99 ], [ 189, 99 ], [ 234, 99 ], [ 207, 99 ], [ 158, 101 ], [ 161, 104 ], [ 185, 107 ], [ 230, 110 ], [ 182, 113 ], [ 165, 117 ], [ 216, 117 ], [ 198, 121 ], [ 231, 125 ], [ 162, 125 ], [ 189, 125 ], [ 234, 125 ], [ 207, 125 ], [ 180, 125 ], [ 171, 125 ], [ 183, 126 ], [ 159, 126 ], [ 225, 126 ], [ 213, 126 ], [ 153, 126 ], [ 228, 126 ], [ 192, 126 ], [ 167, 128 ], [ 231, 130 ], [ 162, 130 ], [ 189, 130 ], [ 234, 130 ], [ 207, 130 ], [ 180, 130 ], [ 171, 130 ], [ 183, 131 ], [ 159, 131 ], [ 225, 131 ], [ 213, 131 ], [ 153, 131 ], [ 228, 131 ], [ 192, 131 ], [ 191, 133 ], [ 218, 136 ], [ 183, 138 ], [ 159, 138 ], [ 225, 138 ], [ 213, 138 ], [ 153, 138 ], [ 228, 138 ], [ 192, 138 ], [ 231, 139 ], [ 162, 139 ], [ 189, 139 ], [ 234, 139 ], [ 207, 139 ], [ 180, 139 ], [ 171, 139 ], [ 170, 141 ], [ 215, 144 ], [ 168, 149 ], [ 201, 149 ], [ 219, 150 ], [ 174, 150 ], [ 195, 150 ], [ 152, 153 ], [ 155, 156 ], [ 158, 159 ], [ 161, 162 ], [ 164, 165 ], [ 167, 168 ], [ 170, 171 ], [ 173, 174 ], [ 176, 177 ], [ 179, 180 ], [ 182, 183 ], [ 185, 186 ], [ 188, 189 ], [ 191, 192 ], [ 194, 195 ], [ 197, 198 ], [ 200, 201 ], [ 203, 204 ], [ 206, 207 ], [ 209, 210 ], [ 212, 213 ], [ 215, 216 ], [ 218, 219 ], [ 221, 222 ], [ 224, 225 ], [ 227, 228 ], [ 230, 231 ], [ 233, 234 ] ]
[ "s=input()\nans=0\ni=0\nc=-1\ntmp1=0#Sが連続した数\ntmp2=0\nx=0\ny=0\nwhile i<len(s):\n if c==-1:\n if s[i]==\"S\":\n tmp1=1\n c=0\n else:\n tmp2+=1\n c=1\n elif c==0:\n if s[i]==\"S\":\n tmp1+=1\n else:\n tmp2+=1\n c=1\n elif c==1:\n if s[i]==\"S\":\n if tmp1>=tmp2:\n tmp1=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp2=0\n tmp1=0\n c=0\n tmp1+=1\n else:\n tmp2+=1\n if i==len(s)-1:\n if tmp1>=tmp2:\n x+=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp1=0\n i+=1\n \n #print(ans,tmp1,tmp2,x,y)\nprint(x+y)", "s=input()", "s", "input()", "input", "ans=0", "ans", "0", "i=0", "i", "0", "c=-1", "c", "-1", "tmp1=0", "tmp1", "0", "tmp2=0", "tmp2", "0", "x=0", "x", "0", "y=0", "y", "0", "while i<len(s):\n if c==-1:\n if s[i]==\"S\":\n tmp1=1\n c=0\n else:\n tmp2+=1\n c=1\n elif c==0:\n if s[i]==\"S\":\n tmp1+=1\n else:\n tmp2+=1\n c=1\n elif c==1:\n if s[i]==\"S\":\n if tmp1>=tmp2:\n tmp1=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp2=0\n tmp1=0\n c=0\n tmp1+=1\n else:\n tmp2+=1\n if i==len(s)-1:\n if tmp1>=tmp2:\n x+=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp1=0\n i+=1\n \n #print(ans,tmp1,tmp2,x,y)", "i<len(s)", "i", "len(s)", "len", "s", "if c==-1:\n if s[i]==\"S\":\n tmp1=1\n c=0\n else:\n tmp2+=1\n c=1\n elif c==0:\n if s[i]==\"S\":\n tmp1+=1\n else:\n tmp2+=1\n c=1\n elif c==1:\n if s[i]==\"S\":\n if tmp1>=tmp2:\n tmp1=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp2=0\n tmp1=0\n c=0\n tmp1+=1\n else:\n tmp2+=1\n ", "c==-1", "c", "-1", "if s[i]==\"S\":\n tmp1=1\n c=0\n else:\n tmp2+=1\n c=1\n ", "s[i]==\"S\"", "s[i]", "s", "i", "\"S\"", "tmp1=1", "tmp1", "1", "c=0", "c", "0", "tmp2+=1", "tmp2", "1", "c=1", "c", "1", "elif c==0:\n if s[i]==\"S\":\n tmp1+=1\n else:\n tmp2+=1\n c=1\n ", "c==0", "c", "0", "if s[i]==\"S\":\n tmp1+=1\n else:\n tmp2+=1\n c=1\n ", "s[i]==\"S\"", "s[i]", "s", "i", "\"S\"", "tmp1+=1", "tmp1", "1", "tmp2+=1", "tmp2", "1", "c=1", "c", "1", "elif c==1:\n if s[i]==\"S\":\n if tmp1>=tmp2:\n tmp1=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp2=0\n tmp1=0\n c=0\n tmp1+=1\n else:\n tmp2+=1\n ", "c==1", "c", "1", "if s[i]==\"S\":\n if tmp1>=tmp2:\n tmp1=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp2=0\n tmp1=0\n c=0\n tmp1+=1\n else:\n tmp2+=1\n ", "s[i]==\"S\"", "s[i]", "s", "i", "\"S\"", "if tmp1>=tmp2:\n tmp1=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp2=0\n tmp1=0\n ", "tmp1>=tmp2", "tmp1", "tmp2", "tmp1=tmp1-tmp2", "tmp1", "tmp1-tmp2", "tmp1", "tmp2", "tmp2=0", "tmp2", "0", "y+=tmp2-tmp1", "y", "tmp2-tmp1", "tmp2", "tmp1", "tmp2=0", "tmp2", "0", "tmp1=0", "tmp1", "0", "c=0", "c", "0", "tmp1+=1", "tmp1", "1", "tmp2+=1", "tmp2", "1", "if i==len(s)-1:\n if tmp1>=tmp2:\n x+=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp1=0\n ", "i==len(s)-1", "i", "len(s)-1", "len(s)", "len", "s", "1", "if tmp1>=tmp2:\n x+=tmp1-tmp2\n tmp2=0\n else:\n y+=tmp2-tmp1\n tmp1=0\n ", "tmp1>=tmp2", "tmp1", "tmp2", "x+=tmp1-tmp2", "x", "tmp1-tmp2", "tmp1", "tmp2", "tmp2=0", "tmp2", "0", "y+=tmp2-tmp1", "y", "tmp2-tmp1", "tmp2", "tmp1", "tmp1=0", "tmp1", "0", "i+=1", "i", "1", "print(x+y)", "print", "x+y", "x", "y", "tmp2+=1", "1", "tmp2", "c=-1", "-1", "c", "tmp2=0", "0", "tmp2", "tmp1=0", "0", "tmp1", "i=0", "0", "i", "x+=tmp1-tmp2", "tmp1-tmp2", "x", "tmp1=0", "0", "tmp1", "y+=tmp2-tmp1", "tmp2-tmp1", "y", "c=1", "1", "c", "tmp1=0", "0", "tmp1", "tmp2+=1", "1", "tmp2", "c=0", "0", "c", "tmp1=tmp1-tmp2", "tmp1-tmp2", "tmp1", "tmp2=0", "0", "tmp2", "y=0", "0", "y", "s=input()", "input()", "s", "x=0", "0", "x", "c=1", "1", "c", "tmp1=1", "1", "tmp1", "ans=0", "0", "ans", "tmp2+=1", "1", "tmp2", "i+=1", "1", "i", "y+=tmp2-tmp1", "tmp2-tmp1", "y", "c=0", "0", "c", "tmp2=0", "0", "tmp2", "tmp2=0", "0", "tmp2", "tmp1+=1", "1", "tmp1", "tmp1+=1", "1", "tmp1" ]
s=input() ans=0 i=0 c=-1 tmp1=0#Sが連続した数 tmp2=0 x=0 y=0 while i<len(s): if c==-1: if s[i]=="S": tmp1=1 c=0 else: tmp2+=1 c=1 elif c==0: if s[i]=="S": tmp1+=1 else: tmp2+=1 c=1 elif c==1: if s[i]=="S": if tmp1>=tmp2: tmp1=tmp1-tmp2 tmp2=0 else: y+=tmp2-tmp1 tmp2=0 tmp1=0 c=0 tmp1+=1 else: tmp2+=1 if i==len(s)-1: if tmp1>=tmp2: x+=tmp1-tmp2 tmp2=0 else: y+=tmp2-tmp1 tmp1=0 i+=1 #print(ans,tmp1,tmp2,x,y) print(x+y)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 13, 0, 13, 13, 0, 13, 17, 4, 13, 2, 2, 17, 13, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 42, 2 ], [ 39, 6 ], [ 54, 9 ], [ 13, 12 ], [ 43, 12 ], [ 12, 16 ], [ 48, 19 ], [ 49, 23 ], [ 40, 23 ], [ 52, 23 ], [ 55, 24 ], [ 46, 24 ], [ 45, 26 ], [ 49, 27 ], [ 40, 27 ], [ 52, 27 ], [ 51, 29 ], [ 46, 36 ], [ 55, 36 ], [ 52, 37 ], [ 49, 37 ], [ 40, 37 ], [ 39, 40 ], [ 42, 43 ], [ 49, 45 ], [ 40, 45 ], [ 52, 45 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ] ]
[ "x = input()\ndepth = 0\nmin_depth = 0\nfor char in x:\n if char == 'T':\n depth -= 1\n if depth < min_depth:\n min_depth = depth\n else:\n depth += 1\nprint(-2*min_depth-depth)", "x = input()", "x", "input()", "input", "depth = 0", "depth", "0", "min_depth = 0", "min_depth", "0", "for char in x:\n if char == 'T':\n depth -= 1\n if depth < min_depth:\n min_depth = depth\n else:\n depth += 1", "char", "x", "if char == 'T':\n depth -= 1\n if depth < min_depth:\n min_depth = depth\n else:\n depth += 1", "char == 'T'", "char", "'T'", "depth -= 1", "depth", "1", "if depth < min_depth:\n min_depth = depth\n ", "depth < min_depth", "depth", "min_depth", "min_depth = depth", "min_depth", "depth", "depth += 1", "depth", "1", "print(-2*min_depth-depth)", "print", "-2*min_depth-depth", "-2*min_depth", "-2", "min_depth", "depth", "depth = 0", "0", "depth", "x = input()", "input()", "x", "min_depth = depth", "depth", "min_depth", "depth -= 1", "1", "depth", "depth += 1", "1", "depth", "min_depth = 0", "0", "min_depth" ]
x = input() depth = 0 min_depth = 0 for char in x: if char == 'T': depth -= 1 if depth < min_depth: min_depth = depth else: depth += 1 print(-2*min_depth-depth)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 13, 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, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 58, 2 ], [ 52, 6 ], [ 49, 9 ], [ 59, 12 ], [ 15, 14 ], [ 59, 19 ], [ 59, 23 ], [ 14, 24 ], [ 43, 27 ], [ 53, 31 ], [ 56, 31 ], [ 44, 31 ], [ 46, 34 ], [ 55, 37 ], [ 47, 41 ], [ 50, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "X = input()\ns_cnt = 0\nans = len(X)\nfor i in range(len(X)):\n if(X[i] == \"S\"):\n s_cnt += 1\n else:\n if(s_cnt > 0):\n ans -= 2\n s_cnt -= 1\nprint(ans)", "X = input()", "X", "input()", "input", "s_cnt = 0", "s_cnt", "0", "ans = len(X)", "ans", "len(X)", "len", "X", "for i in range(len(X)):\n if(X[i] == \"S\"):\n s_cnt += 1\n else:\n if(s_cnt > 0):\n ans -= 2\n s_cnt -= 1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if(X[i] == \"S\"):\n s_cnt += 1\n else:\n if(s_cnt > 0):\n ans -= 2\n s_cnt -= 1", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "s_cnt += 1", "s_cnt", "1", "if(s_cnt > 0):\n ans -= 2\n s_cnt -= 1", "s_cnt > 0", "s_cnt", "0", "ans -= 2", "ans", "2", "s_cnt -= 1", "s_cnt", "1", "print(ans)", "print", "ans", "s_cnt += 1", "1", "s_cnt", "ans -= 2", "2", "ans", "ans = len(X)", "len(X)", "ans", "s_cnt = 0", "0", "s_cnt", "s_cnt -= 1", "1", "s_cnt", "X = input()", "input()", "X" ]
X = input() s_cnt = 0 ans = len(X) for i in range(len(X)): if(X[i] == "S"): s_cnt += 1 else: if(s_cnt > 0): ans -= 2 s_cnt -= 1 print(ans)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 13, 14, 2, 13, 17, 8, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 58, 3 ], [ 61, 7 ], [ 12, 11 ], [ 59, 11 ], [ 62, 17 ], [ 62, 21 ], [ 11, 23 ], [ 11, 26 ], [ 62, 31 ], [ 62, 36 ], [ 62, 40 ], [ 11, 42 ], [ 11, 45 ], [ 62, 49 ], [ 11, 51 ], [ 62, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "from collections import deque\nS = input()\nd = deque()\nfor s in S:\n if len(d) == 0:\n d.append(s)\n elif s == \"T\":\n d.pop() if d[-1] == \"S\" else d.append(s)\n elif s == \"S\":\n d.append(s)\nprint(len(d))", "from collections import deque", "S = input()", "S", "input()", "input", "d = deque()", "d", "deque()", "deque", "for s in S:\n if len(d) == 0:\n d.append(s)\n elif s == \"T\":\n d.pop() if d[-1] == \"S\" else d.append(s)\n elif s == \"S\":\n d.append(s)", "s", "S", "if len(d) == 0:\n d.append(s)\n elif s == \"T\":\n d.pop() if d[-1] == \"S\" else d.append(s)\n elif s == \"S\":\n d.append(s)", "len(d) == 0", "len(d)", "len", "d", "0", "d.append(s)", "d.append", "d", "append", "s", "elif s == \"T\":\n d.pop() if d[-1] == \"S\" else d.append(s)\n ", "s == \"T\"", "s", "\"T\"", "d.pop() if d[-1] == \"S\" else d.append(s)", "d[-1] == \"S\"", "d[-1]", "d", "-1", "\"S\"", "d.pop()", "d.pop", "d", "pop", "d.append(s)", "d.append", "d", "append", "s", "elif s == \"S\":\n d.append(s)", "s == \"S\"", "s", "\"S\"", "d.append(s)", "d.append", "d", "append", "s", "print(len(d))", "print", "len(d)", "len", "d", "S = input()", "input()", "S", "d = deque()", "deque()", "d" ]
from collections import deque S = input() d = deque() for s in S: if len(d) == 0: d.append(s) elif s == "T": d.pop() if d[-1] == "S" else d.append(s) elif s == "S": d.append(s) print(len(d))
[ 7, 0, 13, 4, 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, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 38, 2 ], [ 44, 8 ], [ 53, 10 ], [ 14, 13 ], [ 39, 13 ], [ 13, 17 ], [ 41, 20 ], [ 54, 24 ], [ 48, 24 ], [ 42, 24 ], [ 47, 27 ], [ 50, 30 ], [ 51, 35 ], [ 45, 35 ], [ 48, 36 ], [ 42, 36 ], [ 54, 36 ], [ 38, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "X = list(input())\nnt, ns = 0, 0\nfor x in X:\n if x == 'S':\n ns += 1\n elif ns > 0:\n ns -= 1\n else:\n nt += 1\nprint(nt+ns)", "X = list(input())", "X", "list(input())", "list", "input()", "input", "nt, ns = 0, 0", "nt", "0", "ns", "0", "for x in X:\n if x == 'S':\n ns += 1\n elif ns > 0:\n ns -= 1\n else:\n nt += 1", "x", "X", "if x == 'S':\n ns += 1\n elif ns > 0:\n ns -= 1\n else:\n nt += 1", "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", "print(nt+ns)", "print", "nt+ns", "nt", "ns", "X = list(input())", "list(input())", "X", "ns += 1", "1", "ns", "nt, ns = 0, 0", "0", "nt", "ns -= 1", "1", "ns", "nt += 1", "1", "nt", "ns = 0, 0", "0", "ns" ]
X = list(input()) nt, ns = 0, 0 for x in X: if x == 'S': ns += 1 elif ns > 0: ns -= 1 else: nt += 1 print(nt+ns)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 45, 2 ], [ 42, 6 ], [ 36, 9 ], [ 13, 12 ], [ 46, 12 ], [ 12, 16 ], [ 51, 19 ], [ 39, 22 ], [ 48, 25 ], [ 43, 28 ], [ 49, 28 ], [ 40, 29 ], [ 52, 29 ], [ 37, 29 ], [ 49, 33 ], [ 43, 33 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "# 05\n\ns = input()\nx = 0\ny = 0\nfor i in s:\n if i == 'S':\n y -= 1\n else:\n y += 1\n #print(x, y)\n x = max(x, y)\n \nprint(x*2)", "s = input()", "s", "input()", "input", "x = 0", "x", "0", "y = 0", "y", "0", "for i in s:\n if i == 'S':\n y -= 1\n else:\n y += 1\n #print(x, y)\n x = max(x, y)\n ", "i", "s", "if i == 'S':\n y -= 1\n else:\n y += 1\n #print(x, y)\n ", "i == 'S'", "i", "'S'", "y -= 1", "y", "1", "y += 1", "y", "1", "x = max(x, y)", "x", "max(x, y)", "max", "x", "y", "print(x*2)", "print", "x*2", "x", "2", "y = 0", "0", "y", "y += 1", "1", "y", "x = 0", "0", "x", "s = input()", "input()", "s", "x = max(x, y)", "max(x, y)", "x", "y -= 1", "1", "y" ]
# 05 s = input() x = 0 y = 0 for i in s: if i == 'S': y -= 1 else: y += 1 #print(x, y) x = max(x, y) print(x*2)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 2, 4, 13, 13, 13, 17, 14, 40, 13, 13, 0, 13, 2, 2, 17, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 2, 4, 13, 13, 13, 17, 0, 13, 2, 4, 13, 13, 13, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 124, 2 ], [ 118, 6 ], [ 103, 9 ], [ 109, 12 ], [ 16, 15 ], [ 125, 20 ], [ 125, 25 ], [ 15, 26 ], [ 119, 29 ], [ 113, 29 ], [ 101, 29 ], [ 131, 29 ], [ 121, 32 ], [ 125, 37 ], [ 15, 38 ], [ 130, 41 ], [ 125, 47 ], [ 15, 48 ], [ 119, 51 ], [ 113, 51 ], [ 101, 51 ], [ 131, 51 ], [ 127, 54 ], [ 104, 58 ], [ 134, 58 ], [ 116, 58 ], [ 122, 58 ], [ 119, 59 ], [ 113, 59 ], [ 101, 59 ], [ 131, 59 ], [ 104, 63 ], [ 134, 63 ], [ 116, 63 ], [ 122, 63 ], [ 119, 64 ], [ 113, 64 ], [ 101, 64 ], [ 131, 64 ], [ 115, 66 ], [ 104, 70 ], [ 134, 70 ], [ 116, 70 ], [ 122, 70 ], [ 119, 71 ], [ 113, 71 ], [ 101, 71 ], [ 131, 71 ], [ 100, 73 ], [ 133, 76 ], [ 112, 79 ], [ 106, 82 ], [ 134, 86 ], [ 116, 86 ], [ 122, 86 ], [ 104, 86 ], [ 113, 87 ], [ 101, 87 ], [ 131, 87 ], [ 119, 87 ], [ 136, 90 ], [ 125, 94 ], [ 107, 95 ], [ 128, 95 ], [ 110, 95 ], [ 137, 98 ], [ 100, 101 ], [ 103, 104 ], [ 106, 107 ], [ 109, 110 ], [ 112, 113 ], [ 115, 116 ], [ 118, 119 ], [ 121, 122 ], [ 124, 125 ], [ 127, 128 ], [ 130, 131 ], [ 133, 134 ], [ 136, 137 ] ]
[ "x = input()\nt_num = 0\ns_num = 0\ntotal = 0\nfor i in range(len(x)):\n if x[i] == 'S' and t_num == 0:\n s_num += 1\n elif x[i] == 'T':\n t_num += 1\n elif x[i] == 'S' and t_num > 0:\n total += min(s_num, t_num) * 2\n if s_num >= t_num:\n s_num = 1 + s_num - t_num\n t_num = 0\n else:\n s_num = 1\n t_num = 0\ntotal += min(s_num, t_num) * 2\nans = len(x) - total\nprint(ans)", "x = input()", "x", "input()", "input", "t_num = 0", "t_num", "0", "s_num = 0", "s_num", "0", "total = 0", "total", "0", "for i in range(len(x)):\n if x[i] == 'S' and t_num == 0:\n s_num += 1\n elif x[i] == 'T':\n t_num += 1\n elif x[i] == 'S' and t_num > 0:\n total += min(s_num, t_num) * 2\n if s_num >= t_num:\n s_num = 1 + s_num - t_num\n t_num = 0\n else:\n s_num = 1\n t_num = 0", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == 'S' and t_num == 0:\n s_num += 1\n elif x[i] == 'T':\n t_num += 1\n elif x[i] == 'S' and t_num > 0:\n total += min(s_num, t_num) * 2\n if s_num >= t_num:\n s_num = 1 + s_num - t_num\n t_num = 0\n else:\n s_num = 1\n t_num = 0", "x[i] == 'S' and t_num == 0", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "t_num == 0", "t_num", "0", "s_num += 1", "s_num", "1", "elif x[i] == 'T':\n t_num += 1\n ", "x[i] == 'T'", "x[i]", "x", "i", "'T'", "t_num += 1", "t_num", "1", "elif x[i] == 'S' and t_num > 0:\n total += min(s_num, t_num) * 2\n if s_num >= t_num:\n s_num = 1 + s_num - t_num\n t_num = 0\n else:\n s_num = 1\n t_num = 0", "x[i] == 'S' and t_num > 0", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "t_num > 0", "t_num", "0", "total += min(s_num, t_num) * 2", "total", "min(s_num, t_num) * 2", "min(s_num, t_num)", "min", "s_num", "t_num", "2", "if s_num >= t_num:\n s_num = 1 + s_num - t_num\n t_num = 0\n else:\n s_num = 1\n t_num = 0", "s_num >= t_num", "s_num", "t_num", "s_num = 1 + s_num - t_num", "s_num", "1 + s_num - t_num", "1 + s_num", "1", "s_num", "t_num", "t_num = 0", "t_num", "0", "s_num = 1", "s_num", "1", "t_num = 0", "t_num", "0", "total += min(s_num, t_num) * 2", "total", "min(s_num, t_num) * 2", "min(s_num, t_num)", "min", "s_num", "t_num", "2", "ans = len(x) - total", "ans", "len(x) - total", "len(x)", "len", "x", "total", "print(ans)", "print", "ans", "t_num = 0", "0", "t_num", "s_num = 0", "0", "s_num", "total += min(s_num, t_num) * 2", "min(s_num, t_num) * 2", "total", "total = 0", "0", "total", "t_num = 0", "0", "t_num", "s_num = 1 + s_num - t_num", "1 + s_num - t_num", "s_num", "t_num = 0", "0", "t_num", "s_num += 1", "1", "s_num", "x = input()", "input()", "x", "total += min(s_num, t_num) * 2", "min(s_num, t_num) * 2", "total", "t_num += 1", "1", "t_num", "s_num = 1", "1", "s_num", "ans = len(x) - total", "len(x) - total", "ans" ]
x = input() t_num = 0 s_num = 0 total = 0 for i in range(len(x)): if x[i] == 'S' and t_num == 0: s_num += 1 elif x[i] == 'T': t_num += 1 elif x[i] == 'S' and t_num > 0: total += min(s_num, t_num) * 2 if s_num >= t_num: s_num = 1 + s_num - t_num t_num = 0 else: s_num = 1 t_num = 0 total += min(s_num, t_num) * 2 ans = len(x) - total print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 13, 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 44, 2 ], [ 50, 6 ], [ 50, 9 ], [ 50, 11 ], [ 14, 13 ], [ 45, 13 ], [ 13, 17 ], [ 41, 20 ], [ 39, 24 ], [ 54, 24 ], [ 42, 24 ], [ 56, 27 ], [ 53, 30 ], [ 54, 35 ], [ 42, 35 ], [ 39, 35 ], [ 57, 36 ], [ 48, 36 ], [ 50, 39 ], [ 41, 42 ], [ 44, 45 ], [ 50, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "S = input()\na = b = c = 0\nfor s in S:\n if s == 'S':\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1\nprint(a+b)", "S = input()", "S", "input()", "input", "a = b = c = 0", "a", "0", "= b = c = 0", "b", "0", "c", "for s in S:\n if s == 'S':\n a += 1\n else:\n if a == 0:\n b += 1\n else:\n a -= 1", "s", "S", "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 = b = c = 0", "0", "a", "a += 1", "1", "a", "S = input()", "input()", "S", "b = c = 0", "0", "b", "c = 0", "0", "c", "a -= 1", "1", "a", "b += 1", "1", "b" ]
S = input() a = b = c = 0 for s in S: if s == 'S': a += 1 else: if a == 0: b += 1 else: a -= 1 print(a+b)
[ 7, 15, 15, 15, 15, 15, 15, 15, 15, 15, 13, 15, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 12, 13, 12, 13, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 13, 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, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13 ]
[ [ 94, 29 ], [ 86, 31 ], [ 91, 33 ], [ 76, 36 ], [ 95, 39 ], [ 42, 41 ], [ 95, 46 ], [ 95, 50 ], [ 41, 51 ], [ 70, 54 ], [ 92, 58 ], [ 74, 58 ], [ 71, 58 ], [ 73, 61 ], [ 82, 64 ], [ 83, 68 ], [ 77, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 82, 83 ], [ 91, 92 ], [ 94, 95 ] ]
[ "from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf\nfrom itertools import accumulate,permutations,combinations,product,combinations_with_replacement\nfrom collections import deque,defaultdict,Counter\nfrom bisect import bisect_left,bisect_right\nfrom operator import itemgetter\nfrom heapq import heapify,heappop,heappush\nfrom copy import deepcopy\nfrom time import time\nimport string\nimport sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nx = input()\ns = 0\nans = len(x)\nfor i in range(len(x)):\n if x[i] == 'S':\n s += 1\n else:\n if s > 0 :\n s -= 1\n ans -= 2\n\nprint(ans)", "from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf", "from itertools import accumulate,permutations,combinations,product,combinations_with_replacement", "from collections import deque,defaultdict,Counter", "from bisect import bisect_left,bisect_right", "from operator import itemgetter", "from heapq import heapify,heappop,heappush", "from copy import deepcopy", "from time import time", "import string", "string", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "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())", "LIST", "x = input()", "x", "input()", "input", "s = 0", "s", "0", "ans = len(x)", "ans", "len(x)", "len", "x", "for i in range(len(x)):\n if x[i] == 'S':\n s += 1\n else:\n if s > 0 :\n s -= 1\n ans -= 2", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == 'S':\n s += 1\n else:\n if s > 0 :\n s -= 1\n ans -= 2", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "s += 1", "s", "1", "if s > 0 :\n s -= 1\n ans -= 2", "s > 0", "s", "0", "s -= 1", "s", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "s += 1", "1", "s", "s -= 1", "1", "s", "ans = len(x)", "len(x)", "ans", "def INT() : return int(input())", "def INT() : return int(input())", "INT", "ans -= 2", "2", "ans", "def input() : return sys.stdin.readline().strip()", "def input() : return sys.stdin.readline().strip()", "input", "def LIST() : return list(MAP())", "def LIST() : return list(MAP())", "LIST", "s = 0", "0", "s", "x = input()", "input()", "x", "def MAP() : return map(int,input().split())", "def MAP() : return map(int,input().split())", "MAP" ]
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf from itertools import accumulate,permutations,combinations,product,combinations_with_replacement from collections import deque,defaultdict,Counter from bisect import bisect_left,bisect_right from operator import itemgetter from heapq import heapify,heappop,heappush from copy import deepcopy from time import time import string import sys sys.setrecursionlimit(10 ** 7) def input() : return sys.stdin.readline().strip() def INT() : return int(input()) def MAP() : return map(int,input().split()) def LIST() : return list(MAP()) x = input() s = 0 ans = len(x) for i in range(len(x)): if x[i] == 'S': s += 1 else: if s > 0 : s -= 1 ans -= 2 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 14, 13, 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 ]
[ [ 41, 2 ], [ 44, 6 ], [ 44, 9 ], [ 13, 12 ], [ 42, 12 ], [ 12, 16 ], [ 38, 21 ], [ 35, 24 ], [ 39, 29 ], [ 45, 29 ], [ 36, 30 ], [ 33, 30 ], [ 44, 33 ], [ 35, 36 ], [ 38, 39 ], [ 41, 42 ], [ 44, 45 ] ]
[ "x=input()\ns=t=0\nfor i in x:\n if i==\"S\":s+=1\n else:\n if s:\n s-=1\n else:\n t+=1\nprint(s+t)", "x=input()", "x", "input()", "input", "s=t=0", "s", "0", "=t=0", "t", "0", "for i in x:\n if i==\"S\":s+=1\n else:\n if s:\n s-=1\n else:\n t+=1", "i", "x", "if i==\"S\":s+=1\n else:\n if s:\n s-=1\n else:\n t+=1", "i==\"S\"", "i", "\"S\"", "if s:\n s-=1\n else:\n t+=1", "s", "s-=1", "s", "1", "t+=1", "t", "1", "print(s+t)", "print", "s+t", "s", "t", "t=0", "0", "t", "t+=1", "1", "t", "s-=1", "1", "s", "x=input()", "input()", "x", "s=t=0", "0", "s" ]
x=input() s=t=0 for i in x: if i=="S":s+=1 else: if s: s-=1 else: t+=1 print(s+t)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 18, 13, 13, 17, 17, 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, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 60, 2 ], [ 66, 8 ], [ 61, 11 ], [ 54, 16 ], [ 67, 19 ], [ 61, 19 ], [ 63, 21 ], [ 72, 24 ], [ 28, 27 ], [ 55, 30 ], [ 67, 34 ], [ 61, 34 ], [ 27, 35 ], [ 69, 38 ], [ 75, 43 ], [ 57, 46 ], [ 76, 51 ], [ 70, 51 ], [ 64, 51 ], [ 58, 52 ], [ 73, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "X = str(input())\nX = X.replace(\"ST\",\"\")\nlx = len(X)\ns_count = 0\nt_count = 0\nfor i in range(lx):\n if X[i] == \"S\":\n s_count += 1\n else:\n if s_count:\n s_count -= 1\n else:\n t_count += 1\n \nprint(s_count + t_count)", "X = str(input())", "X", "str(input())", "str", "input()", "input", "X = X.replace(\"ST\",\"\")", "X", "X.replace(\"ST\",\"\")", "X.replace", "X", "replace", "\"ST\"", "\"\"", "lx = len(X)", "lx", "len(X)", "len", "X", "s_count = 0", "s_count", "0", "t_count = 0", "t_count", "0", "for i in range(lx):\n if X[i] == \"S\":\n s_count += 1\n else:\n if s_count:\n s_count -= 1\n else:\n t_count += 1\n ", "i", "range(lx)", "range", "lx", "if X[i] == \"S\":\n s_count += 1\n else:\n if s_count:\n s_count -= 1\n else:\n t_count += 1\n ", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "s_count += 1", "s_count", "1", "if s_count:\n s_count -= 1\n else:\n t_count += 1\n ", "s_count", "s_count -= 1", "s_count", "1", "t_count += 1", "t_count", "1", "print(s_count + t_count)", "print", "s_count + t_count", "s_count", "t_count", "lx = len(X)", "len(X)", "lx", "t_count += 1", "1", "t_count", "X = str(input())", "str(input())", "X", "s_count = 0", "0", "s_count", "X = X.replace(\"ST\",\"\")", "X.replace(\"ST\",\"\")", "X", "s_count += 1", "1", "s_count", "t_count = 0", "0", "t_count", "s_count -= 1", "1", "s_count" ]
X = str(input()) X = X.replace("ST","") lx = len(X) s_count = 0 t_count = 0 for i in range(lx): if X[i] == "S": s_count += 1 else: if s_count: s_count -= 1 else: t_count += 1 print(s_count + t_count)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 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, 40, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 57, 2 ], [ 63, 6 ], [ 58, 9 ], [ 60, 11 ], [ 69, 14 ], [ 78, 17 ], [ 21, 20 ], [ 64, 23 ], [ 58, 27 ], [ 20, 28 ], [ 66, 31 ], [ 58, 36 ], [ 20, 37 ], [ 61, 41 ], [ 73, 41 ], [ 67, 41 ], [ 72, 44 ], [ 75, 47 ], [ 64, 52 ], [ 76, 54 ], [ 79, 54 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "x = input()\nn = len(x)\ns = 0\nt = 0\ncou = 0\n\nfor i in range(n):\n if x[i] == \"S\":\n s += 1\n elif x[i]== \"T\":\n if s >= 1:\n s -= 1\n cou += 1\nprint(n - cou * 2)", "x = input()", "x", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "s = 0", "s", "0", "t = 0", "t", "0", "cou = 0", "cou", "0", "for i in range(n):\n if x[i] == \"S\":\n s += 1\n elif x[i]== \"T\":\n if s >= 1:\n s -= 1\n cou += 1", "i", "range(n)", "range", "n", "if x[i] == \"S\":\n s += 1\n elif x[i]== \"T\":\n if s >= 1:\n s -= 1\n cou += 1", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "s += 1", "s", "1", "elif x[i]== \"T\":\n if s >= 1:\n s -= 1\n cou += 1", "x[i]== \"T\"", "x[i]", "x", "i", "\"T\"", "if s >= 1:\n s -= 1\n cou += 1", "s >= 1", "s", "1", "s -= 1", "s", "1", "cou += 1", "cou", "1", "print(n - cou * 2)", "print", "n - cou * 2", "n", "cou * 2", "cou", "2", "x = input()", "input()", "x", "s = 0", "0", "s", "n = len(x)", "len(x)", "n", "s += 1", "1", "s", "t = 0", "0", "t", "s -= 1", "1", "s", "cou += 1", "1", "cou", "cou = 0", "0", "cou" ]
x = input() n = len(x) s = 0 t = 0 cou = 0 for i in range(n): if x[i] == "S": s += 1 elif x[i]== "T": if s >= 1: s -= 1 cou += 1 print(n - cou * 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, 17, 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, 0, 13, 17, 0, 13, 4, 13, 13, 29, 13, 23, 13, 14, 2, 13, 17, 0, 13, 4, 13, 4, 13, 2, 17, 4, 13, 31, 13, 10, 4, 13, 10, 12, 13, 10, 18, 13, 10, 12, 13 ]
[ [ 92, 4 ], [ 15, 14 ], [ 93, 18 ], [ 14, 21 ], [ 26, 25 ], [ 29, 28 ], [ 33, 32 ], [ 68, 32 ], [ 32, 36 ], [ 28, 40 ], [ 32, 42 ], [ 32, 45 ], [ 28, 51 ], [ 28, 55 ], [ 59, 58 ], [ 62, 61 ], [ 28, 64 ], [ 61, 66 ], [ 58, 66 ], [ 25, 66 ], [ 68, 68 ], [ 86, 74 ], [ 96, 76 ], [ 90, 82 ], [ 87, 84 ], [ 86, 87 ], [ 92, 93 ] ]
[ "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 ans = 0\n q = deque()\n for x in X:\n if x == \"S\":\n q.append(x)\n elif x == \"T\":\n if len(q) > 0:\n q.popleft()\n else:\n ans += 1\n ans += len(q)\n return ans\n\n\nif __name__ == '__main__':\n inputs = read()\n print(\"%s\" % 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 ans = 0\n q = deque()\n for x in X:\n if x == \"S\":\n q.append(x)\n elif x == \"T\":\n if len(q) > 0:\n q.popleft()\n else:\n ans += 1\n ans += len(q)\n return ans", "solve", "ans = 0", "ans", "0", "q = deque()", "q", "deque()", "deque", "for x in X:\n if x == \"S\":\n q.append(x)\n elif x == \"T\":\n if len(q) > 0:\n q.popleft()\n else:\n ans += 1\n ", "x", "X", "if x == \"S\":\n q.append(x)\n elif x == \"T\":\n if len(q) > 0:\n q.popleft()\n else:\n ans += 1\n ", "x == \"S\"", "x", "\"S\"", "q.append(x)", "q.append", "q", "append", "x", "elif x == \"T\":\n if len(q) > 0:\n q.popleft()\n else:\n ans += 1\n ", "x == \"T\"", "x", "\"T\"", "if len(q) > 0:\n q.popleft()\n else:\n ans += 1\n ", "len(q) > 0", "len(q)", "len", "q", "0", "q.popleft()", "q.popleft", "q", "popleft", "ans += 1", "ans", "1", "ans += len(q)", "ans", "len(q)", "len", "q", "return ans", "ans", "X", "X", "if __name__ == '__main__':\n inputs = read()\n print(\"%s\" % solve(*inputs))", "__name__ == '__main__'", "__name__", "'__main__'", "inputs = read()", "inputs", "read()", "read", "print(\"%s\" % solve(*inputs))", "print", "\"%s\" % solve(*inputs)", "\"%s\"", "solve(*inputs)", "solve", "*inputs", "inputs", "inputs = read()", "read()", "inputs", "def solve(X):\n ans = 0\n q = deque()\n for x in X:\n if x == \"S\":\n q.append(x)\n elif x == \"T\":\n if len(q) > 0:\n q.popleft()\n else:\n ans += 1\n ans += len(q)\n return ans", "def solve(X):\n ans = 0\n q = deque()\n for x in X:\n if x == \"S\":\n q.append(x)\n elif x == \"T\":\n if len(q) > 0:\n q.popleft()\n else:\n ans += 1\n ans += len(q)\n return ans", "solve", "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" ]
import sys input = sys.stdin.readline from collections import deque def read(): X = input().strip() return X, def solve(X): ans = 0 q = deque() for x in X: if x == "S": q.append(x) elif x == "T": if len(q) > 0: q.popleft() else: ans += 1 ans += len(q) return ans if __name__ == '__main__': inputs = read() print("%s" % solve(*inputs))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 14, 2, 13, 17, 0, 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 ]
[ [ 46, 2 ], [ 49, 8 ], [ 55, 11 ], [ 15, 14 ], [ 47, 14 ], [ 14, 18 ], [ 52, 21 ], [ 14, 25 ], [ 50, 29 ], [ 44, 29 ], [ 53, 29 ], [ 43, 32 ], [ 58, 35 ], [ 59, 40 ], [ 56, 40 ], [ 44, 41 ], [ 53, 41 ], [ 50, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "x = list(input())\ncnt = 0\na = 0\nfor i in x:\n if i == 'S':\n cnt += 1\n elif i == 'T':\n if cnt > 0:\n cnt -= 1\n else:\n a += 1\nprint(a+cnt)", "x = list(input())", "x", "list(input())", "list", "input()", "input", "cnt = 0", "cnt", "0", "a = 0", "a", "0", "for i in x:\n if i == 'S':\n cnt += 1\n elif i == 'T':\n if cnt > 0:\n cnt -= 1\n else:\n a += 1", "i", "x", "if i == 'S':\n cnt += 1\n elif i == 'T':\n if cnt > 0:\n cnt -= 1\n else:\n a += 1", "i == 'S'", "i", "'S'", "cnt += 1", "cnt", "1", "elif i == 'T':\n if cnt > 0:\n cnt -= 1\n else:\n a += 1", "i == 'T'", "i", "'T'", "if cnt > 0:\n cnt -= 1\n else:\n a += 1", "cnt > 0", "cnt", "0", "cnt -= 1", "cnt", "1", "a += 1", "a", "1", "print(a+cnt)", "print", "a+cnt", "a", "cnt", "cnt -= 1", "1", "cnt", "x = list(input())", "list(input())", "x", "cnt = 0", "0", "cnt", "cnt += 1", "1", "cnt", "a = 0", "0", "a", "a += 1", "1", "a" ]
x = list(input()) cnt = 0 a = 0 for i in x: if i == 'S': cnt += 1 elif i == 'T': if cnt > 0: cnt -= 1 else: a += 1 print(a+cnt)
[ 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, 4, 13, 13, 17, 4, 18, 13, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 0, 13, 4, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 18, 13, 10, 12, 13 ]
[ [ 77, 5 ], [ 15, 14 ], [ 78, 18 ], [ 22, 21 ], [ 26, 25 ], [ 14, 25 ], [ 21, 31 ], [ 21, 35 ], [ 25, 37 ], [ 25, 40 ], [ 21, 44 ], [ 25, 46 ], [ 21, 50 ], [ 21, 55 ], [ 21, 59 ], [ 25, 61 ], [ 64, 63 ], [ 21, 66 ], [ 63, 69 ], [ 81, 75 ], [ 77, 78 ] ]
[ "import sys\nfrom collections import deque\n\ninput = sys.stdin.readline\n\n\ndef main():\n X = input().rstrip()\n\n stack = deque()\n for x in X:\n if len(stack) == 0:\n stack.append(x)\n else:\n if x == \"S\":\n stack.append(x)\n else:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(x)\n ans = len(stack)\n\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 x in X:\n if len(stack) == 0:\n stack.append(x)\n else:\n if x == \"S\":\n stack.append(x)\n else:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(x)\n ans = len(stack)\n\n print(ans)", "main", "X = input().rstrip()", "X", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "stack = deque()", "stack", "deque()", "deque", "for x in X:\n if len(stack) == 0:\n stack.append(x)\n else:\n if x == \"S\":\n stack.append(x)\n else:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(x)\n ", "x", "X", "if len(stack) == 0:\n stack.append(x)\n else:\n if x == \"S\":\n stack.append(x)\n else:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(x)\n ", "len(stack) == 0", "len(stack)", "len", "stack", "0", "stack.append(x)", "stack.append", "stack", "append", "x", "if x == \"S\":\n stack.append(x)\n else:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(x)\n ", "x == \"S\"", "x", "\"S\"", "stack.append(x)", "stack.append", "stack", "append", "x", "if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(x)\n ", "stack[-1] == \"S\"", "stack[-1]", "stack", "-1", "\"S\"", "stack.pop()", "stack.pop", "stack", "pop", "stack.append(x)", "stack.append", "stack", "append", "x", "ans = len(stack)", "ans", "len(stack)", "len", "stack", "print(ans)", "print", "ans", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input", "def main():\n X = input().rstrip()\n\n stack = deque()\n for x in X:\n if len(stack) == 0:\n stack.append(x)\n else:\n if x == \"S\":\n stack.append(x)\n else:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(x)\n ans = len(stack)\n\n print(ans)", "def main():\n X = input().rstrip()\n\n stack = deque()\n for x in X:\n if len(stack) == 0:\n stack.append(x)\n else:\n if x == \"S\":\n stack.append(x)\n else:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(x)\n ans = len(stack)\n\n print(ans)", "main" ]
import sys from collections import deque input = sys.stdin.readline def main(): X = input().rstrip() stack = deque() for x in X: if len(stack) == 0: stack.append(x) else: if x == "S": stack.append(x) else: if stack[-1] == "S": stack.pop() else: stack.append(x) ans = len(stack) print(ans) if __name__ == "__main__": main()
[ 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, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 54, 2 ], [ 48, 8 ], [ 51, 11 ], [ 15, 14 ], [ 55, 19 ], [ 55, 23 ], [ 14, 24 ], [ 57, 27 ], [ 60, 32 ], [ 45, 35 ], [ 55, 42 ], [ 61, 43 ], [ 49, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "X = list(input())\n\ncnt = 0\ns = 0\nfor i in range(len(X)):\n if X[i] == \"S\":\n s += 1\n else:\n if s:\n cnt += 2\n s -= 1\nprint(len(X)-cnt)", "X = list(input())", "X", "list(input())", "list", "input()", "input", "cnt = 0", "cnt", "0", "s = 0", "s", "0", "for i in range(len(X)):\n if X[i] == \"S\":\n s += 1\n else:\n if s:\n cnt += 2\n s -= 1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == \"S\":\n s += 1\n else:\n if s:\n cnt += 2\n s -= 1", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "s += 1", "s", "1", "if s:\n cnt += 2\n s -= 1", "s", "cnt += 2", "cnt", "2", "s -= 1", "s", "1", "print(len(X)-cnt)", "print", "len(X)-cnt", "len(X)", "len", "X", "cnt", "s -= 1", "1", "s", "cnt = 0", "0", "cnt", "s = 0", "0", "s", "X = list(input())", "list(input())", "X", "s += 1", "1", "s", "cnt += 2", "2", "cnt" ]
X = list(input()) cnt = 0 s = 0 for i in range(len(X)): if X[i] == "S": s += 1 else: if s: cnt += 2 s -= 1 print(len(X)-cnt)
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 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, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 12, 11 ], [ 15, 14 ], [ 4, 14 ], [ 14, 18 ], [ 22, 21 ], [ 8, 25 ], [ 28, 25 ], [ 21, 25 ], [ 29, 28 ], [ 32, 31 ], [ 31, 35 ], [ 11, 35 ], [ 44, 41 ] ]
[ "def main():\n x = input()\n\n s = 0\n count = 0\n for cur in x:\n if cur == \"S\":\n s += 1\n else:\n if s != 0:\n s -= 1\n else:\n count += 2\n\n print(count)\n\n\nif __name__ == '__main__':\n main()", "def main():\n x = input()\n\n s = 0\n count = 0\n for cur in x:\n if cur == \"S\":\n s += 1\n else:\n if s != 0:\n s -= 1\n else:\n count += 2\n\n print(count)", "main", "x = input()", "x", "input()", "input", "s = 0", "s", "0", "count = 0", "count", "0", "for cur in x:\n if cur == \"S\":\n s += 1\n else:\n if s != 0:\n s -= 1\n else:\n count += 2\n\n ", "cur", "x", "if cur == \"S\":\n s += 1\n else:\n if s != 0:\n s -= 1\n else:\n count += 2\n\n ", "cur == \"S\"", "cur", "\"S\"", "s += 1", "s", "1", "if s != 0:\n s -= 1\n else:\n count += 2\n\n ", "s != 0", "s", "0", "s -= 1", "s", "1", "count += 2", "count", "2", "print(count)", "print", "count", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n x = input()\n\n s = 0\n count = 0\n for cur in x:\n if cur == \"S\":\n s += 1\n else:\n if s != 0:\n s -= 1\n else:\n count += 2\n\n print(count)", "def main():\n x = input()\n\n s = 0\n count = 0\n for cur in x:\n if cur == \"S\":\n s += 1\n else:\n if s != 0:\n s -= 1\n else:\n count += 2\n\n print(count)", "main" ]
def main(): x = input() s = 0 count = 0 for cur in x: if cur == "S": s += 1 else: if s != 0: s -= 1 else: count += 2 print(count) if __name__ == '__main__': main()
[ 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, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 42, 2 ], [ 45, 6 ], [ 33, 9 ], [ 13, 12 ], [ 43, 12 ], [ 12, 16 ], [ 39, 19 ], [ 48, 24 ], [ 36, 27 ], [ 37, 31 ], [ 46, 31 ], [ 33, 34 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ] ]
[ "X = input()\nans = 0\nsc = 0\nfor x in X:\n if x == \"S\":\n sc += 1\n else:\n if sc:\n sc -= 1\n else:\n ans += 2\nprint(ans)", "X = input()", "X", "input()", "input", "ans = 0", "ans", "0", "sc = 0", "sc", "0", "for x in X:\n if x == \"S\":\n sc += 1\n else:\n if sc:\n sc -= 1\n else:\n ans += 2", "x", "X", "if x == \"S\":\n sc += 1\n else:\n if sc:\n sc -= 1\n else:\n ans += 2", "x == \"S\"", "x", "\"S\"", "sc += 1", "sc", "1", "if sc:\n sc -= 1\n else:\n ans += 2", "sc", "sc -= 1", "sc", "1", "ans += 2", "ans", "2", "print(ans)", "print", "ans", "sc = 0", "0", "sc", "ans += 2", "2", "ans", "sc += 1", "1", "sc", "X = input()", "input()", "X", "ans = 0", "0", "ans", "sc -= 1", "1", "sc" ]
X = input() ans = 0 sc = 0 for x in X: if x == "S": sc += 1 else: if sc: sc -= 1 else: ans += 2 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 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, 0, 13, 17, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 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, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 86, 2 ], [ 107, 6 ], [ 116, 9 ], [ 83, 12 ], [ 110, 15 ], [ 87, 18 ], [ 101, 20 ], [ 24, 23 ], [ 111, 26 ], [ 87, 30 ], [ 23, 31 ], [ 80, 34 ], [ 87, 39 ], [ 23, 40 ], [ 108, 44 ], [ 99, 44 ], [ 96, 44 ], [ 81, 44 ], [ 89, 47 ], [ 95, 50 ], [ 113, 53 ], [ 96, 58 ], [ 81, 58 ], [ 108, 58 ], [ 99, 58 ], [ 114, 61 ], [ 90, 61 ], [ 117, 61 ], [ 93, 61 ], [ 104, 64 ], [ 98, 67 ], [ 92, 70 ], [ 111, 75 ], [ 105, 77 ], [ 102, 77 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ], [ 110, 111 ], [ 113, 114 ], [ 116, 117 ] ]
[ "x = input()\ncs = 0\nct = 0\nprev = \"\"\nn = len(x)\ncnt = 0\nfor i in range(n):\n if x[i] ==\"S\":\n cs+=1\n elif x[i] ==\"T\":\n if cs>0:\n ct+=1\n else:\n cs = 0\n ct = 0\n if cs>0 and ct>0:\n cnt+=1\n cs-=1\n ct-=1\nprint(n-cnt*2)", "x = input()", "x", "input()", "input", "cs = 0", "cs", "0", "ct = 0", "ct", "0", "prev = \"\"", "prev", "\"\"", "n = len(x)", "n", "len(x)", "len", "x", "cnt = 0", "cnt", "0", "for i in range(n):\n if x[i] ==\"S\":\n cs+=1\n elif x[i] ==\"T\":\n if cs>0:\n ct+=1\n else:\n cs = 0\n ct = 0\n if cs>0 and ct>0:\n cnt+=1\n cs-=1\n ct-=1", "i", "range(n)", "range", "n", "if x[i] ==\"S\":\n cs+=1\n elif x[i] ==\"T\":\n if cs>0:\n ct+=1\n else:\n cs = 0\n ct = 0\n ", "x[i] ==\"S\"", "x[i]", "x", "i", "\"S\"", "cs+=1", "cs", "1", "elif x[i] ==\"T\":\n if cs>0:\n ct+=1\n ", "x[i] ==\"T\"", "x[i]", "x", "i", "\"T\"", "if cs>0:\n ct+=1\n ", "cs>0", "cs", "0", "ct+=1", "ct", "1", "cs = 0", "cs", "0", "ct = 0", "ct", "0", "if cs>0 and ct>0:\n cnt+=1\n cs-=1\n ct-=1", "cs>0 and ct>0", "cs>0", "cs", "0", "ct>0", "ct", "0", "cnt+=1", "cnt", "1", "cs-=1", "cs", "1", "ct-=1", "ct", "1", "print(n-cnt*2)", "print", "n-cnt*2", "n", "cnt*2", "cnt", "2", "cs+=1", "1", "cs", "prev = \"\"", "\"\"", "prev", "x = input()", "input()", "x", "ct+=1", "1", "ct", "ct-=1", "1", "ct", "cs = 0", "0", "cs", "cs-=1", "1", "cs", "cnt = 0", "0", "cnt", "cnt+=1", "1", "cnt", "cs = 0", "0", "cs", "n = len(x)", "len(x)", "n", "ct = 0", "0", "ct", "ct = 0", "0", "ct" ]
x = input() cs = 0 ct = 0 prev = "" n = len(x) cnt = 0 for i in range(n): if x[i] =="S": cs+=1 elif x[i] =="T": if cs>0: ct+=1 else: cs = 0 ct = 0 if cs>0 and ct>0: cnt+=1 cs-=1 ct-=1 print(n-cnt*2)
[ 7, 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, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 48, 2 ], [ 39, 6 ], [ 51, 8 ], [ 12, 11 ], [ 49, 11 ], [ 11, 15 ], [ 36, 18 ], [ 40, 22 ], [ 43, 22 ], [ 37, 22 ], [ 45, 25 ], [ 42, 28 ], [ 46, 33 ], [ 52, 33 ], [ 43, 34 ], [ 37, 34 ], [ 40, 34 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "x=input()\ns,a=0,0\nfor i in x:\n if i==\"S\":\n s+=1\n elif s==0:\n a+=1\n else:\n s-=1\nprint(a+s)", "x=input()", "x", "input()", "input", "s,a=0,0", "s", "0", "a", "0", "for i in x:\n if i==\"S\":\n s+=1\n elif s==0:\n a+=1\n else:\n s-=1", "i", "x", "if i==\"S\":\n s+=1\n elif s==0:\n a+=1\n else:\n s-=1", "i==\"S\"", "i", "\"S\"", "s+=1", "s", "1", "elif s==0:\n a+=1\n ", "s==0", "s", "0", "a+=1", "a", "1", "s-=1", "s", "1", "print(a+s)", "print", "a+s", "a", "s", "s+=1", "1", "s", "s,a=0,0", "0", "s", "s-=1", "1", "s", "a+=1", "1", "a", "x=input()", "input()", "x", "a=0,0", "0", "a" ]
x=input() s,a=0,0 for i in x: if i=="S": s+=1 elif s==0: a+=1 else: s-=1 print(a+s)
[ 7, 12, 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, 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 ], [ 9, 8 ], [ 12, 11 ], [ 15, 14 ], [ 4, 19 ], [ 4, 23 ], [ 14, 24 ], [ 28, 27 ], [ 4, 33 ], [ 14, 34 ], [ 27, 37 ], [ 8, 37 ], [ 43, 37 ], [ 41, 40 ], [ 44, 43 ], [ 4, 50 ], [ 40, 51 ], [ 11, 51 ], [ 60, 57 ] ]
[ "def main():\n X = input()\n delcnt = 0\n delans = 0\n for i in range(len(X)):\n if X[i]=='S':\n delcnt += 1\n if X[i]=='T' and delcnt>0:\n delans +=2\n delcnt -=1\n print(len(X)-delans)\n\n\n\nif __name__ == '__main__':\n main()", "def main():\n X = input()\n delcnt = 0\n delans = 0\n for i in range(len(X)):\n if X[i]=='S':\n delcnt += 1\n if X[i]=='T' and delcnt>0:\n delans +=2\n delcnt -=1\n print(len(X)-delans)", "main", "X = input()", "X", "input()", "input", "delcnt = 0", "delcnt", "0", "delans = 0", "delans", "0", "for i in range(len(X)):\n if X[i]=='S':\n delcnt += 1\n if X[i]=='T' and delcnt>0:\n delans +=2\n delcnt -=1\n ", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i]=='S':\n delcnt += 1\n ", "X[i]=='S'", "X[i]", "X", "i", "'S'", "delcnt += 1", "delcnt", "1", "if X[i]=='T' and delcnt>0:\n delans +=2\n delcnt -=1\n ", "X[i]=='T' and delcnt>0", "X[i]=='T'", "X[i]", "X", "i", "'T'", "delcnt>0", "delcnt", "0", "delans +=2", "delans", "2", "delcnt -=1", "delcnt", "1", "print(len(X)-delans)", "print", "len(X)-delans", "len(X)", "len", "X", "delans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n X = input()\n delcnt = 0\n delans = 0\n for i in range(len(X)):\n if X[i]=='S':\n delcnt += 1\n if X[i]=='T' and delcnt>0:\n delans +=2\n delcnt -=1\n print(len(X)-delans)", "def main():\n X = input()\n delcnt = 0\n delans = 0\n for i in range(len(X)):\n if X[i]=='S':\n delcnt += 1\n if X[i]=='T' and delcnt>0:\n delans +=2\n delcnt -=1\n print(len(X)-delans)", "main" ]
def main(): X = input() delcnt = 0 delans = 0 for i in range(len(X)): if X[i]=='S': delcnt += 1 if X[i]=='T' and delcnt>0: delans +=2 delcnt -=1 print(len(X)-delans) if __name__ == '__main__': main()
[ 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, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 47, 2 ], [ 44, 6 ], [ 44, 9 ], [ 13, 12 ], [ 48, 12 ], [ 12, 16 ], [ 50, 19 ], [ 45, 23 ], [ 57, 23 ], [ 51, 23 ], [ 53, 26 ], [ 56, 29 ], [ 48, 36 ], [ 54, 38 ], [ 42, 38 ], [ 44, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "x = input()\nans = c = 0\nfor i in x:\n if i=='S':\n c += 1\n else:\n if c>0:\n ans += 1\n c -= 1\nprint(len(x)-ans*2)", "x = input()", "x", "input()", "input", "ans = c = 0", "ans", "0", "= c = 0", "c", "0", "for i in x:\n if i=='S':\n c += 1\n else:\n if c>0:\n ans += 1\n c -= 1", "i", "x", "if i=='S':\n c += 1\n else:\n if c>0:\n ans += 1\n c -= 1", "i=='S'", "i", "'S'", "c += 1", "c", "1", "if c>0:\n ans += 1\n c -= 1", "c>0", "c", "0", "ans += 1", "ans", "1", "c -= 1", "c", "1", "print(len(x)-ans*2)", "print", "len(x)-ans*2", "len(x)", "len", "x", "ans*2", "ans", "2", "ans = c = 0", "0", "ans", "c = 0", "0", "c", "x = input()", "input()", "x", "c += 1", "1", "c", "ans += 1", "1", "ans", "c -= 1", "1", "c" ]
x = input() ans = c = 0 for i in x: if i=='S': c += 1 else: if c>0: ans += 1 c -= 1 print(len(x)-ans*2)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 39, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 13, 0, 13, 13, 3, 0, 13, 17, 28, 13, 4, 13, 13, 4, 13, 13, 14, 40, 18, 13, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 14, 2, 2, 4, 13, 13, 17, 17, 24, 18, 13, 17, 28, 13, 4, 13, 2, 4, 13, 13, 17, 14, 40, 18, 13, 2, 17, 2, 13, 17, 2, 18, 13, 2, 2, 17, 13, 17, 13, 0, 13, 2, 2, 18, 13, 2, 2, 17, 13, 17, 13, 17, 0, 13, 17, 0, 13, 2, 18, 13, 2, 17, 2, 13, 17, 17, 0, 13, 2, 2, 18, 13, 2, 2, 17, 13, 17, 13, 18, 13, 2, 17, 2, 13, 17, 4, 13, 2, 4, 13, 13, 13, 10, 2, 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, 17, 13, 10, 2, 13, 10, 39, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 219, 2 ], [ 210, 8 ], [ 192, 11 ], [ 189, 14 ], [ 220, 17 ], [ 20, 19 ], [ 220, 24 ], [ 220, 28 ], [ 19, 29 ], [ 193, 30 ], [ 222, 32 ], [ 19, 33 ], [ 183, 36 ], [ 40, 39 ], [ 223, 42 ], [ 190, 42 ], [ 220, 45 ], [ 220, 49 ], [ 39, 50 ], [ 193, 51 ], [ 205, 51 ], [ 181, 51 ], [ 193, 54 ], [ 205, 54 ], [ 181, 54 ], [ 180, 57 ], [ 204, 60 ], [ 211, 64 ], [ 184, 66 ], [ 214, 66 ], [ 196, 66 ], [ 195, 68 ], [ 213, 71 ], [ 211, 75 ], [ 214, 77 ], [ 196, 77 ], [ 184, 77 ], [ 198, 79 ], [ 186, 82 ], [ 211, 89 ], [ 211, 94 ], [ 98, 97 ], [ 211, 103 ], [ 211, 108 ], [ 97, 112 ], [ 211, 116 ], [ 97, 120 ], [ 187, 122 ], [ 217, 122 ], [ 202, 122 ], [ 177, 124 ], [ 211, 128 ], [ 97, 132 ], [ 187, 134 ], [ 217, 134 ], [ 202, 134 ], [ 201, 137 ], [ 207, 140 ], [ 211, 143 ], [ 97, 147 ], [ 216, 151 ], [ 211, 155 ], [ 97, 159 ], [ 187, 161 ], [ 217, 161 ], [ 202, 161 ], [ 211, 163 ], [ 97, 167 ], [ 220, 174 ], [ 208, 175 ], [ 178, 175 ], [ 199, 175 ], [ 177, 178 ], [ 180, 181 ], [ 183, 184 ], [ 186, 187 ], [ 189, 190 ], [ 192, 193 ], [ 195, 196 ], [ 198, 199 ], [ 201, 202 ], [ 204, 205 ], [ 207, 208 ], [ 210, 211 ], [ 213, 214 ], [ 216, 217 ], [ 219, 220 ], [ 19, 222 ], [ 222, 223 ] ]
[ "x=list(input())\nnum=[]\ns=\"S\"\ncnt=len(x)\nfor i in range(len(x)):\n if x[i]==s:\n cnt=i\n break\ncnt2=0\nfor i in range(cnt,len(x)):\n if x[i]!=s:\n if s==\"T\":\n s=\"S\"\n else:\n s=\"T\"\n num.append(cnt2)\n cnt2=1\n else:\n cnt2+=1\nnum.append(cnt2)\nans=0\nnum3=0\nif len(num)%2==1:\n del(num[-1])\nfor i in range(len(num)//2):\n if num[-2*(i+1)]>=num[-2*i-1]+num3:\n ans+=(num[-2*i-1]+num3)*2\n num3=0\n else:\n ans+=(num[-2*(i+1)])*2\n num3=num[-2*i-1]+num3-num[-2*(i+1)]\nprint(len(x)-ans)", "x=list(input())", "x", "list(input())", "list", "input()", "input", "num=[]", "num", "[]", "s=\"S\"", "s", "\"S\"", "cnt=len(x)", "cnt", "len(x)", "len", "x", "for i in range(len(x)):\n if x[i]==s:\n cnt=i\n break", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i]==s:\n cnt=i\n break", "x[i]==s", "x[i]", "x", "i", "s", "cnt=i", "cnt", "i", "break", "cnt2=0", "cnt2", "0", "for i in range(cnt,len(x)):\n if x[i]!=s:\n if s==\"T\":\n s=\"S\"\n else:\n s=\"T\"\n num.append(cnt2)\n cnt2=1\n else:\n cnt2+=1", "i", "range(cnt,len(x))", "range", "cnt", "len(x)", "len", "x", "if x[i]!=s:\n if s==\"T\":\n s=\"S\"\n else:\n s=\"T\"\n num.append(cnt2)\n cnt2=1\n else:\n cnt2+=1", "x[i]!=s", "x[i]", "x", "i", "s", "if s==\"T\":\n s=\"S\"\n else:\n s=\"T\"\n ", "s==\"T\"", "s", "\"T\"", "s=\"S\"", "s", "\"S\"", "s=\"T\"", "s", "\"T\"", "num.append(cnt2)", "num.append", "num", "append", "cnt2", "cnt2=1", "cnt2", "1", "cnt2+=1", "cnt2", "1", "num.append(cnt2)", "num.append", "num", "append", "cnt2", "ans=0", "ans", "0", "num3=0", "num3", "0", "if len(num)%2==1:\n del(num[-1])", "len(num)%2==1", "len(num)%2", "len(num)", "len", "num", "2", "1", "del(num[-1])", "num[-1]", "num", "-1", "for i in range(len(num)//2):\n if num[-2*(i+1)]>=num[-2*i-1]+num3:\n ans+=(num[-2*i-1]+num3)*2\n num3=0\n else:\n ans+=(num[-2*(i+1)])*2\n num3=num[-2*i-1]+num3-num[-2*(i+1)]", "i", "range(len(num)//2)", "range", "len(num)//2", "len(num)", "len", "num", "2", "if num[-2*(i+1)]>=num[-2*i-1]+num3:\n ans+=(num[-2*i-1]+num3)*2\n num3=0\n else:\n ans+=(num[-2*(i+1)])*2\n num3=num[-2*i-1]+num3-num[-2*(i+1)]", "num[-2*(i+1)]>=num[-2*i-1]+num3", "num[-2*(i+1)]", "num", "-2*(i+1)", "-2", "i+1", "i", "1", "num[-2*i-1]+num3", "num[-2*i-1]", "num", "-2*i-1", "-2*i", "-2", "i", "1", "num3", "ans+=(num[-2*i-1]+num3)*2", "ans", "(num[-2*i-1]+num3)*2", "num[-2*i-1]+num3", "num[-2*i-1]", "num", "-2*i-1", "-2*i", "-2", "i", "1", "num3", "2", "num3=0", "num3", "0", "ans+=(num[-2*(i+1)])*2", "ans", "(num[-2*(i+1)])*2", "num[-2*(i+1)]", "num", "-2*(i+1)", "-2", "i+1", "i", "1", "2", "num3=num[-2*i-1]+num3-num[-2*(i+1)]", "num3", "num[-2*i-1]+num3-num[-2*(i+1)]", "num[-2*i-1]+num3", "num[-2*i-1]", "num", "-2*i-1", "-2*i", "-2", "i", "1", "num3", "num[-2*(i+1)]", "num", "-2*(i+1)", "-2", "i+1", "i", "1", "print(len(x)-ans)", "print", "len(x)-ans", "len(x)", "len", "x", "ans", "ans+=(num[-2*i-1]+num3)*2", "(num[-2*i-1]+num3)*2", "ans", "s=\"S\"", "\"S\"", "s", "cnt2=0", "0", "cnt2", "num3=0", "0", "num3", "cnt=len(x)", "len(x)", "cnt", "s=\"S\"", "\"S\"", "s", "cnt2=1", "1", "cnt2", "ans=0", "0", "ans", "num3=0", "0", "num3", "s=\"T\"", "\"T\"", "s", "ans+=(num[-2*(i+1)])*2", "(num[-2*(i+1)])*2", "ans", "num=[]", "[]", "num", "cnt2+=1", "1", "cnt2", "num3=num[-2*i-1]+num3-num[-2*(i+1)]", "num[-2*i-1]+num3-num[-2*(i+1)]", "num3", "x=list(input())", "list(input())", "x", "cnt=i", "i", "cnt" ]
x=list(input()) num=[] s="S" cnt=len(x) for i in range(len(x)): if x[i]==s: cnt=i break cnt2=0 for i in range(cnt,len(x)): if x[i]!=s: if s=="T": s="S" else: s="T" num.append(cnt2) cnt2=1 else: cnt2+=1 num.append(cnt2) ans=0 num3=0 if len(num)%2==1: del(num[-1]) for i in range(len(num)//2): if num[-2*(i+1)]>=num[-2*i-1]+num3: ans+=(num[-2*i-1]+num3)*2 num3=0 else: ans+=(num[-2*(i+1)])*2 num3=num[-2*i-1]+num3-num[-2*(i+1)] print(len(x)-ans)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 13, 28, 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, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13 ]
[ [ 47, 2 ], [ 62, 6 ], [ 48, 9 ], [ 44, 11 ], [ 59, 14 ], [ 63, 15 ], [ 18, 17 ], [ 63, 20 ], [ 48, 24 ], [ 17, 25 ], [ 56, 28 ], [ 45, 32 ], [ 51, 32 ], [ 57, 32 ], [ 50, 35 ], [ 53, 38 ], [ 54, 42 ], [ 60, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 63, 59 ], [ 59, 60 ], [ 62, 63 ] ]
[ "X = input()\nn = len(X)\nS_waitng_for_T = 0\nans = n\nfor i in range(n):\n if X[i] == 'S':\n S_waitng_for_T += 1\n else:\n if S_waitng_for_T > 0:\n S_waitng_for_T -= 1\n ans -= 2\nprint(ans)", "X = input()", "X", "input()", "input", "n = len(X)", "n", "len(X)", "len", "X", "S_waitng_for_T = 0", "S_waitng_for_T", "0", "ans = n", "ans", "n", "for i in range(n):\n if X[i] == 'S':\n S_waitng_for_T += 1\n else:\n if S_waitng_for_T > 0:\n S_waitng_for_T -= 1\n ans -= 2", "i", "range(n)", "range", "n", "if X[i] == 'S':\n S_waitng_for_T += 1\n else:\n if S_waitng_for_T > 0:\n S_waitng_for_T -= 1\n ans -= 2", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "S_waitng_for_T += 1", "S_waitng_for_T", "1", "if S_waitng_for_T > 0:\n S_waitng_for_T -= 1\n ans -= 2", "S_waitng_for_T > 0", "S_waitng_for_T", "0", "S_waitng_for_T -= 1", "S_waitng_for_T", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "S_waitng_for_T = 0", "0", "S_waitng_for_T", "X = input()", "input()", "X", "S_waitng_for_T -= 1", "1", "S_waitng_for_T", "ans -= 2", "2", "ans", "S_waitng_for_T += 1", "1", "S_waitng_for_T", "ans = n", "n", "ans", "n = len(X)", "len(X)", "n" ]
X = input() n = len(X) S_waitng_for_T = 0 ans = n for i in range(n): if X[i] == 'S': S_waitng_for_T += 1 else: if S_waitng_for_T > 0: S_waitng_for_T -= 1 ans -= 2 print(ans)
[ 7, 12, 13, 15, 13, 0, 13, 18, 18, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 15, 15, 15, 15, 15, 13, 0, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 40, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 27, 26 ], [ 6, 30 ], [ 34, 33 ], [ 37, 36 ], [ 40, 39 ], [ 26, 39 ], [ 39, 43 ], [ 47, 46 ], [ 33, 50 ], [ 56, 50 ], [ 46, 50 ], [ 54, 53 ], [ 57, 56 ], [ 53, 61 ], [ 36, 61 ], [ 56, 62 ], [ 46, 62 ], [ 33, 62 ], [ 71, 68 ] ]
[ "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n import math\n #from math import gcd\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n s = input().rstrip()\n a = 0\n res = 0\n for i in s:\n if i == 'S':\n a += 1\n else:\n if a <= 0:\n res += 1\n else:\n a -= 1\n print(res+a)\n\nif __name__ == '__main__':\n main()", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n import math\n #from math import gcd\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n s = input().rstrip()\n a = 0\n res = 0\n for i in s:\n if i == 'S':\n a += 1\n else:\n if a <= 0:\n res += 1\n else:\n a -= 1\n print(res+a)", "main", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "sys.setrecursionlimit(10**7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**7", "10", "7", "from collections import Counter, deque", "from itertools import combinations, permutations, accumulate, groupby, product", "from bisect import bisect_left,bisect_right", "from heapq import heapify, heappop, heappush", "import math", "math", "s = input().rstrip()", "s", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "a = 0", "a", "0", "res = 0", "res", "0", "for i in s:\n if i == 'S':\n a += 1\n else:\n if a <= 0:\n res += 1\n else:\n a -= 1\n ", "i", "s", "if i == 'S':\n a += 1\n else:\n if a <= 0:\n res += 1\n else:\n a -= 1\n ", "i == 'S'", "i", "'S'", "a += 1", "a", "1", "if a <= 0:\n res += 1\n else:\n a -= 1\n ", "a <= 0", "a", "0", "res += 1", "res", "1", "a -= 1", "a", "1", "print(res+a)", "print", "res+a", "res", "a", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n import math\n #from math import gcd\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n s = input().rstrip()\n a = 0\n res = 0\n for i in s:\n if i == 'S':\n a += 1\n else:\n if a <= 0:\n res += 1\n else:\n a -= 1\n print(res+a)", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n import math\n #from math import gcd\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n s = input().rstrip()\n a = 0\n res = 0\n for i in s:\n if i == 'S':\n a += 1\n else:\n if a <= 0:\n res += 1\n else:\n a -= 1\n print(res+a)", "main" ]
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush import math #from math import gcd #inf = 10**17 #mod = 10**9 + 7 s = input().rstrip() a = 0 res = 0 for i in s: if i == 'S': a += 1 else: if a <= 0: res += 1 else: a -= 1 print(res+a) if __name__ == '__main__': main()
[ 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, 2, 13, 17, 2, 18, 13, 13, 17, 0, 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, 17, 13 ]
[ [ 55, 2 ], [ 58, 6 ], [ 52, 9 ], [ 70, 12 ], [ 16, 15 ], [ 56, 20 ], [ 56, 24 ], [ 15, 25 ], [ 67, 28 ], [ 53, 33 ], [ 62, 33 ], [ 68, 33 ], [ 56, 37 ], [ 15, 38 ], [ 61, 41 ], [ 64, 44 ], [ 65, 49 ], [ 59, 49 ], [ 62, 50 ], [ 68, 50 ], [ 53, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "#import re\nx=input()\nans=0\nns=0\nnt=0\nfor i in range(len(x)):\n if x[i]=='S':\n ns+=1\n elif ns>0 and x[i]=='T':\n ns-=1\n else:\n ans+=1\nprint(ans+ns)", "x=input()", "x", "input()", "input", "ans=0", "ans", "0", "ns=0", "ns", "0", "nt=0", "nt", "0", "for i in range(len(x)):\n if x[i]=='S':\n ns+=1\n elif ns>0 and x[i]=='T':\n ns-=1\n else:\n ans+=1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i]=='S':\n ns+=1\n elif ns>0 and x[i]=='T':\n ns-=1\n else:\n ans+=1", "x[i]=='S'", "x[i]", "x", "i", "'S'", "ns+=1", "ns", "1", "elif ns>0 and x[i]=='T':\n ns-=1\n ", "ns>0 and x[i]=='T'", "ns>0", "ns", "0", "x[i]=='T'", "x[i]", "x", "i", "'T'", "ns-=1", "ns", "1", "ans+=1", "ans", "1", "print(ans+ns)", "print", "ans+ns", "ans", "ns", "ns=0", "0", "ns", "x=input()", "input()", "x", "ans=0", "0", "ans", "ns-=1", "1", "ns", "ans+=1", "1", "ans", "ns+=1", "1", "ns", "nt=0", "0", "nt" ]
#import re x=input() ans=0 ns=0 nt=0 for i in range(len(x)): if x[i]=='S': ns+=1 elif ns>0 and x[i]=='T': ns-=1 else: ans+=1 print(ans+ns)
[ 7, 15, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 17, 14, 2, 2, 13, 17, 2, 40, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 52, 3 ], [ 49, 7 ], [ 11, 10 ], [ 53, 10 ], [ 10, 14 ], [ 50, 18 ], [ 10, 24 ], [ 50, 28 ], [ 50, 31 ], [ 50, 36 ], [ 50, 41 ], [ 50, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "from collections import deque\ns=input()\nd=[]\n\nfor i in s:\n if i==\"S\":\n d.append(\"S\")\n elif i==\"T\" and (not d or d[-1]==\"T\"):\n d.append(\"T\")\n else:\n d.pop()\nprint(len(d))\n ", "from collections import deque", "s=input()", "s", "input()", "input", "d=[]", "d", "[]", "for i in s:\n if i==\"S\":\n d.append(\"S\")\n elif i==\"T\" and (not d or d[-1]==\"T\"):\n d.append(\"T\")\n else:\n d.pop()", "i", "s", "if i==\"S\":\n d.append(\"S\")\n elif i==\"T\" and (not d or d[-1]==\"T\"):\n d.append(\"T\")\n else:\n d.pop()", "i==\"S\"", "i", "\"S\"", "d.append(\"S\")", "d.append", "d", "append", "\"S\"", "elif i==\"T\" and (not d or d[-1]==\"T\"):\n d.append(\"T\")\n ", "i==\"T\" and (not d or d[-1]==\"T\")", "i==\"T\"", "i", "\"T\"", "not d or d[-1]==\"T\"", "not d", "d", "d[-1]==\"T\"", "d[-1]", "d", "-1", "\"T\"", "d.append(\"T\")", "d.append", "d", "append", "\"T\"", "d.pop()", "d.pop", "d", "pop", "print(len(d))", "print", "len(d)", "len", "d", "d=[]", "[]", "d", "s=input()", "input()", "s" ]
from collections import deque s=input() d=[] for i in s: if i=="S": d.append("S") elif i=="T" and (not d or d[-1]=="T"): d.append("T") else: d.pop() print(len(d))
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 4, 18, 13, 13, 13, 14, 2, 13, 17, 42, 40, 4, 13, 13, 17, 14, 2, 4, 18, 17, 13, 18, 13, 39, 17, 17, 24, 18, 13, 39, 17, 3, 4, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 59, 12 ], [ 62, 16 ], [ 20, 19 ], [ 60, 19 ], [ 63, 23 ], [ 19, 25 ], [ 19, 28 ], [ 63, 34 ], [ 63, 43 ], [ 63, 49 ], [ 63, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "# -*- coding: cp932 -*-\n\nimport sys\nimport os\nimport re\nimport datetime\nimport bisect\n\n### main ###\n\nX = input()\n\nrestS = []\nfor c in X:\n #print(\"c = {}\".format(c))\n restS.append(c)\n if c == 'T':\n while(len(restS) >= 2):\n #print(\"restS = {}, last 2 string = {} \".format(restS, restS[-2:]))\n if(\"\".join(restS[-2:]) == 'ST'):\n #print(\"hit\")\n #restS = restS[:-2] # TLE\n del restS[-2:]\n #print(\"new restS = {}\".format(restS))\n else:\n #print(\"no hit\")\n break # out of while\n\nprint(len(restS))", "import sys", "sys", "import os", "os", "import re", "re", "import datetime", "datetime", "import bisect", "bisect", "X = input()", "X", "input()", "input", "restS = []", "restS", "[]", "for c in X:\n #print(\"c = {}\".format(c))\n restS.append(c)\n if c == 'T':\n while(len(restS) >= 2):\n #print(\"restS = {}, last 2 string = {} \".format(restS, restS[-2:]))\n if(\"\".join(restS[-2:]) == 'ST'):\n #print(\"hit\")\n #restS = restS[:-2] # TLE\n del restS[-2:]\n #print(\"new restS = {}\".format(restS))\n else:\n #print(\"no hit\")\n break # out of while", "c", "X", "restS.append(c)", "restS.append", "restS", "append", "c", "if c == 'T':\n while(len(restS) >= 2):\n #print(\"restS = {}, last 2 string = {} \".format(restS, restS[-2:]))\n if(\"\".join(restS[-2:]) == 'ST'):\n #print(\"hit\")\n #restS = restS[:-2] # TLE\n del restS[-2:]\n #print(\"new restS = {}\".format(restS))\n else:\n #print(\"no hit\")\n break # out of while", "c == 'T'", "c", "'T'", "while(len(restS) >= 2):\n #print(\"restS = {}, last 2 string = {} \".format(restS, restS[-2:]))\n if(\"\".join(restS[-2:]) == 'ST'):\n #print(\"hit\")\n #restS = restS[:-2] # TLE\n del restS[-2:]\n #print(\"new restS = {}\".format(restS))\n else:\n #print(\"no hit\")\n break # out of while", "len(restS) >= 2", "len(restS)", "len", "restS", "2", "if(\"\".join(restS[-2:]) == 'ST'):\n #print(\"hit\")\n #restS = restS[:-2] # TLE\n del restS[-2:]\n #print(\"new restS = {}\".format(restS))\n else:\n #print(\"no hit\")\n break # out of while", "\"\".join(restS[-2:]) == 'ST'", "\"\".join(restS[-2:])", "\"\".join", "\"\"", "join", "restS[-2:]", "restS", "-2:", "-2", "'ST'", "del restS[-2:]", "restS[-2:]", "restS", "-2:", "-2", "break", "print(len(restS))", "print", "len(restS)", "len", "restS", "X = input()", "input()", "X", "restS = []", "[]", "restS" ]
# -*- coding: cp932 -*- import sys import os import re import datetime import bisect ### main ### X = input() restS = [] for c in X: #print("c = {}".format(c)) restS.append(c) if c == 'T': while(len(restS) >= 2): #print("restS = {}, last 2 string = {} ".format(restS, restS[-2:])) if("".join(restS[-2:]) == 'ST'): #print("hit") #restS = restS[:-2] # TLE del restS[-2:] #print("new restS = {}".format(restS)) else: #print("no hit") break # out of while print(len(restS))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 2, 4, 13, 13, 17, 2, 18, 13, 13, 17, 2, 18, 13, 17, 17, 0, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 18, 13, 13, 4, 13, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 39, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 62, 2 ], [ 71, 6 ], [ 63, 9 ], [ 65, 11 ], [ 68, 14 ], [ 18, 17 ], [ 72, 20 ], [ 66, 27 ], [ 63, 31 ], [ 17, 32 ], [ 66, 36 ], [ 59, 40 ], [ 66, 44 ], [ 66, 48 ], [ 63, 51 ], [ 17, 52 ], [ 66, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "x = input()\nn = len(x)\n\nstack=[]\nans = 1\nfor i in range(n):\n if(len(stack) > 0 and x[i] == 'T' and stack[-1] == 'S'):\n ans += 1\n stack.pop()\n else:\n stack.append(x[i])\n \nprint(len(stack))", "x = input()", "x", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "stack=[]", "stack", "[]", "ans = 1", "ans", "1", "for i in range(n):\n if(len(stack) > 0 and x[i] == 'T' and stack[-1] == 'S'):\n ans += 1\n stack.pop()\n else:\n stack.append(x[i])\n ", "i", "range(n)", "range", "n", "if(len(stack) > 0 and x[i] == 'T' and stack[-1] == 'S'):\n ans += 1\n stack.pop()\n else:\n stack.append(x[i])\n ", "len(stack) > 0 and x[i] == 'T' and stack[-1] == 'S'", "len(stack) > 0 and x[i] == 'T'", "len(stack) > 0", "len(stack)", "len", "stack", "0", "x[i] == 'T'", "x[i]", "x", "i", "'T'", "stack[-1] == 'S'", "stack[-1]", "stack", "-1", "'S'", "ans += 1", "ans", "1", "stack.pop()", "stack.pop", "stack", "pop", "stack.append(x[i])", "stack.append", "stack", "append", "x[i]", "x", "i", "print(len(stack))", "print", "len(stack)", "len", "stack", "ans += 1", "1", "ans", "x = input()", "input()", "x", "stack=[]", "[]", "stack", "ans = 1", "1", "ans", "n = len(x)", "len(x)", "n" ]
x = input() n = len(x) stack=[] ans = 1 for i in range(n): if(len(stack) > 0 and x[i] == 'T' and stack[-1] == 'S'): ans += 1 stack.pop() else: stack.append(x[i]) 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, 0, 13, 17, 0, 13, 4, 13, 13, 2, 13, 13, 4, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 53, 2 ], [ 47, 6 ], [ 62, 9 ], [ 56, 12 ], [ 16, 15 ], [ 54, 20 ], [ 54, 24 ], [ 15, 25 ], [ 59, 28 ], [ 50, 31 ], [ 65, 34 ], [ 57, 37 ], [ 66, 37 ], [ 60, 39 ], [ 48, 39 ], [ 51, 40 ], [ 63, 40 ], [ 66, 44 ], [ 57, 44 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ] ]
[ "X=input()\nt=0\ns=0\nans=0\nfor i in range(len(X)):\n if X[i]==\"T\":\n t+=1\n else:\n s+=1\n ans=max(ans,t-s)\nprint(ans*2)", "X=input()", "X", "input()", "input", "t=0", "t", "0", "s=0", "s", "0", "ans=0", "ans", "0", "for i in range(len(X)):\n if X[i]==\"T\":\n t+=1\n else:\n s+=1\n ans=max(ans,t-s)", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i]==\"T\":\n t+=1\n else:\n s+=1\n ", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "t+=1", "t", "1", "s+=1", "s", "1", "ans=max(ans,t-s)", "ans", "max(ans,t-s)", "max", "ans", "t-s", "t", "s", "print(ans*2)", "print", "ans*2", "ans", "2", "t=0", "0", "t", "s+=1", "1", "s", "X=input()", "input()", "X", "ans=0", "0", "ans", "t+=1", "1", "t", "s=0", "0", "s", "ans=max(ans,t-s)", "max(ans,t-s)", "ans" ]
X=input() t=0 s=0 ans=0 for i in range(len(X)): if X[i]=="T": t+=1 else: s+=1 ans=max(ans,t-s) print(ans*2)
[ 7, 15, 13, 15, 0, 13, 4, 13, 0, 13, 2, 39, 17, 4, 13, 13, 0, 13, 2, 39, 17, 4, 13, 13, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 18, 13, 13, 17, 0, 18, 13, 13, 17, 0, 13, 4, 13, 4, 13, 13, 0, 13, 4, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 17, 0, 13, 17, 28, 13, 4, 13, 17, 2, 13, 17, 0, 13, 4, 18, 13, 13, 13, 13, 14, 40, 18, 13, 13, 13, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 2, 13, 17, 17, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13 ]
[ [ 120, 5 ], [ 123, 9 ], [ 121, 15 ], [ 111, 17 ], [ 121, 23 ], [ 26, 25 ], [ 121, 30 ], [ 121, 34 ], [ 25, 35 ], [ 41, 38 ], [ 124, 39 ], [ 25, 40 ], [ 46, 43 ], [ 112, 44 ], [ 25, 45 ], [ 126, 48 ], [ 124, 53 ], [ 114, 55 ], [ 112, 60 ], [ 129, 62 ], [ 121, 66 ], [ 132, 69 ], [ 73, 72 ], [ 130, 77 ], [ 108, 80 ], [ 115, 85 ], [ 72, 86 ], [ 127, 90 ], [ 109, 91 ], [ 133, 92 ], [ 118, 92 ], [ 117, 94 ], [ 121, 101 ], [ 118, 104 ], [ 133, 104 ], [ 108, 109 ], [ 111, 112 ], [ 114, 115 ], [ 117, 118 ], [ 120, 121 ], [ 123, 124 ], [ 126, 127 ], [ 129, 130 ], [ 132, 133 ] ]
[ "import bisect\nfrom itertools import accumulate\nX = input()\nS = [0]*(len(X))\nT = [0]*(len(X))\nfor i in range(len(X)):\n if X[i] == \"S\":\n S[i] = 1\n else:\n T[i]=1\nSsum = list(accumulate(S))\nTsum = list(accumulate(T))\nkosu=len(X)//2\ncount=1\nfor i in range(1,kosu+1):\n Tindex = bisect.bisect_left(Tsum, i)\n if Ssum[Tindex]>=count:\n count+=1\nprint(len(X)-(count-1)*2)", "import bisect", "bisect", "from itertools import accumulate", "X = input()", "X", "input()", "input", "S = [0]*(len(X))", "S", "[0]*(len(X))", "[0]", "0", "len(X)", "len", "X", "T = [0]*(len(X))", "T", "[0]*(len(X))", "[0]", "0", "len(X)", "len", "X", "for i in range(len(X)):\n if X[i] == \"S\":\n S[i] = 1\n else:\n T[i]=1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == \"S\":\n S[i] = 1\n else:\n T[i]=1", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "S[i] = 1", "S[i]", "S", "i", "1", "T[i]=1", "T[i]", "T", "i", "1", "Ssum = list(accumulate(S))", "Ssum", "list(accumulate(S))", "list", "accumulate(S)", "accumulate", "S", "Tsum = list(accumulate(T))", "Tsum", "list(accumulate(T))", "list", "accumulate(T)", "accumulate", "T", "kosu=len(X)//2", "kosu", "len(X)//2", "len(X)", "len", "X", "2", "count=1", "count", "1", "for i in range(1,kosu+1):\n Tindex = bisect.bisect_left(Tsum, i)\n if Ssum[Tindex]>=count:\n count+=1", "i", "range(1,kosu+1)", "range", "1", "kosu+1", "kosu", "1", "Tindex = bisect.bisect_left(Tsum, i)", "Tindex", "bisect.bisect_left(Tsum, i)", "bisect.bisect_left", "bisect", "bisect_left", "Tsum", "i", "if Ssum[Tindex]>=count:\n count+=1", "Ssum[Tindex]>=count", "Ssum[Tindex]", "Ssum", "Tindex", "count", "count+=1", "count", "1", "print(len(X)-(count-1)*2)", "print", "len(X)-(count-1)*2", "len(X)", "len", "X", "(count-1)*2", "count-1", "count", "1", "2", "Tindex = bisect.bisect_left(Tsum, i)", "bisect.bisect_left(Tsum, i)", "Tindex", "T = [0]*(len(X))", "[0]*(len(X))", "T", "Tsum = list(accumulate(T))", "list(accumulate(T))", "Tsum", "count+=1", "1", "count", "X = input()", "input()", "X", "S = [0]*(len(X))", "[0]*(len(X))", "S", "Ssum = list(accumulate(S))", "list(accumulate(S))", "Ssum", "kosu=len(X)//2", "len(X)//2", "kosu", "count=1", "1", "count" ]
import bisect from itertools import accumulate X = input() S = [0]*(len(X)) T = [0]*(len(X)) for i in range(len(X)): if X[i] == "S": S[i] = 1 else: T[i]=1 Ssum = list(accumulate(S)) Tsum = list(accumulate(T)) kosu=len(X)//2 count=1 for i in range(1,kosu+1): Tindex = bisect.bisect_left(Tsum, i) if Ssum[Tindex]>=count: count+=1 print(len(X)-(count-1)*2)
[ 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, 0, 13, 2, 13, 13, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 40, 2 ], [ 46, 6 ], [ 49, 9 ], [ 13, 12 ], [ 41, 12 ], [ 12, 16 ], [ 43, 19 ], [ 50, 23 ], [ 56, 23 ], [ 44, 23 ], [ 52, 26 ], [ 55, 29 ], [ 58, 32 ], [ 53, 34 ], [ 47, 34 ], [ 56, 35 ], [ 44, 35 ], [ 50, 35 ], [ 59, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "s = input()\n \nl = 0\nr = 0\nfor si in s:\n if si == \"S\":\n r += 1\n else:\n if r == 0:\n l += 1\n else:\n r -= 1\nans = l + r\nprint(ans)", "s = input()", "s", "input()", "input", "l = 0", "l", "0", "r = 0", "r", "0", "for si in s:\n if si == \"S\":\n r += 1\n else:\n if r == 0:\n l += 1\n else:\n r -= 1", "si", "s", "if si == \"S\":\n r += 1\n else:\n if r == 0:\n l += 1\n else:\n r -= 1", "si == \"S\"", "si", "\"S\"", "r += 1", "r", "1", "if r == 0:\n l += 1\n else:\n r -= 1", "r == 0", "r", "0", "l += 1", "l", "1", "r -= 1", "r", "1", "ans = l + r", "ans", "l + r", "l", "r", "print(ans)", "print", "ans", "s = input()", "input()", "s", "r += 1", "1", "r", "l = 0", "0", "l", "r = 0", "0", "r", "l += 1", "1", "l", "r -= 1", "1", "r", "ans = l + r", "l + r", "ans" ]
s = input() l = 0 r = 0 for si in s: if si == "S": r += 1 else: if r == 0: l += 1 else: r -= 1 ans = l + r print(ans)
[ 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 ]
[ [ 46, 2 ], [ 37, 5 ], [ 9, 8 ], [ 8, 13 ], [ 40, 16 ], [ 47, 20 ], [ 44, 20 ], [ 41, 20 ], [ 34, 23 ], [ 43, 26 ], [ 35, 31 ], [ 38, 31 ], [ 44, 32 ], [ 41, 32 ], [ 47, 32 ], [ 34, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ] ]
[ "l = 0\nans = 0\nfor c in input():\n if c == 'S':\n l += 1\n else:\n if l == 0:\n ans += 1\n else:\n l -= 1\nprint(ans + l)", "l = 0", "l", "0", "ans = 0", "ans", "0", "for c in input():\n if c == 'S':\n l += 1\n else:\n if l == 0:\n ans += 1\n else:\n l -= 1", "c", "input()", "input", "if c == 'S':\n l += 1\n else:\n if l == 0:\n ans += 1\n else:\n l -= 1", "c == 'S'", "c", "'S'", "l += 1", "l", "1", "if l == 0:\n ans += 1\n else:\n l -= 1", "l == 0", "l", "0", "ans += 1", "ans", "1", "l -= 1", "l", "1", "print(ans + l)", "print", "ans + l", "ans", "l", "ans += 1", "1", "ans", "ans = 0", "0", "ans", "l += 1", "1", "l", "l -= 1", "1", "l", "l = 0", "0", "l" ]
l = 0 ans = 0 for c in input(): if c == 'S': l += 1 else: if l == 0: ans += 1 else: l -= 1 print(ans + l)
[ 7, 15, 13, 4, 18, 13, 13, 2, 2, 17, 17, 17, 12, 13, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 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, 17, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 18, 17 ], [ 71, 21 ], [ 24, 23 ], [ 17, 26 ], [ 29, 28 ], [ 32, 31 ], [ 35, 34 ], [ 38, 37 ], [ 23, 40 ], [ 17, 44 ], [ 37, 45 ], [ 49, 48 ], [ 28, 52 ], [ 55, 52 ], [ 48, 52 ], [ 56, 55 ], [ 59, 58 ], [ 23, 63 ], [ 58, 65 ], [ 34, 65 ], [ 74, 68 ] ]
[ "import sys\nsys.setrecursionlimit(10 ** 5 + 10)\n\n\ndef input(): return sys.stdin.readline().strip()\n\n\ndef resolve():\n\n # https://scrapbox.io/fukucchi/%E6%8B%AC%E5%BC%A7%E5%88%97%E3%81%AE%E6%95%B4%E5%90%88%E6%80%A7%E5%95%8F%E9%A1%8C\n # https://atcoder.jp/contests/abc064/tasks/abc064_d\n\n X = str(input())\n N = len(X)\n stack_rem = 0\n need_left = 0\n pop_cnt = 0\n\n for i in range(N):\n if X[i] == 'S':\n stack_rem += 1\n elif stack_rem > 0:\n stack_rem -= 1\n pop_cnt += 1\n print(N-pop_cnt*2)\n\n\nresolve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 5 + 10)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 5 + 10", "10 ** 5", "10", "5", "10", "def input(): return sys.stdin.readline().strip()", "input", "def resolve():\n\n # https://scrapbox.io/fukucchi/%E6%8B%AC%E5%BC%A7%E5%88%97%E3%81%AE%E6%95%B4%E5%90%88%E6%80%A7%E5%95%8F%E9%A1%8C\n # https://atcoder.jp/contests/abc064/tasks/abc064_d\n\n X = str(input())\n N = len(X)\n stack_rem = 0\n need_left = 0\n pop_cnt = 0\n\n for i in range(N):\n if X[i] == 'S':\n stack_rem += 1\n elif stack_rem > 0:\n stack_rem -= 1\n pop_cnt += 1\n print(N-pop_cnt*2)", "resolve", "X = str(input())", "X", "str(input())", "str", "input()", "input", "N = len(X)", "N", "len(X)", "len", "X", "stack_rem = 0", "stack_rem", "0", "need_left = 0", "need_left", "0", "pop_cnt = 0", "pop_cnt", "0", "for i in range(N):\n if X[i] == 'S':\n stack_rem += 1\n elif stack_rem > 0:\n stack_rem -= 1\n pop_cnt += 1\n ", "i", "range(N)", "range", "N", "if X[i] == 'S':\n stack_rem += 1\n elif stack_rem > 0:\n stack_rem -= 1\n pop_cnt += 1\n ", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "stack_rem += 1", "stack_rem", "1", "elif stack_rem > 0:\n stack_rem -= 1\n pop_cnt += 1\n ", "stack_rem > 0", "stack_rem", "0", "stack_rem -= 1", "stack_rem", "1", "pop_cnt += 1", "pop_cnt", "1", "print(N-pop_cnt*2)", "print", "N-pop_cnt*2", "N", "pop_cnt*2", "pop_cnt", "2", "resolve()", "resolve", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "def resolve():\n\n # https://scrapbox.io/fukucchi/%E6%8B%AC%E5%BC%A7%E5%88%97%E3%81%AE%E6%95%B4%E5%90%88%E6%80%A7%E5%95%8F%E9%A1%8C\n # https://atcoder.jp/contests/abc064/tasks/abc064_d\n\n X = str(input())\n N = len(X)\n stack_rem = 0\n need_left = 0\n pop_cnt = 0\n\n for i in range(N):\n if X[i] == 'S':\n stack_rem += 1\n elif stack_rem > 0:\n stack_rem -= 1\n pop_cnt += 1\n print(N-pop_cnt*2)", "def resolve():\n\n # https://scrapbox.io/fukucchi/%E6%8B%AC%E5%BC%A7%E5%88%97%E3%81%AE%E6%95%B4%E5%90%88%E6%80%A7%E5%95%8F%E9%A1%8C\n # https://atcoder.jp/contests/abc064/tasks/abc064_d\n\n X = str(input())\n N = len(X)\n stack_rem = 0\n need_left = 0\n pop_cnt = 0\n\n for i in range(N):\n if X[i] == 'S':\n stack_rem += 1\n elif stack_rem > 0:\n stack_rem -= 1\n pop_cnt += 1\n print(N-pop_cnt*2)", "resolve" ]
import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): # https://scrapbox.io/fukucchi/%E6%8B%AC%E5%BC%A7%E5%88%97%E3%81%AE%E6%95%B4%E5%90%88%E6%80%A7%E5%95%8F%E9%A1%8C # https://atcoder.jp/contests/abc064/tasks/abc064_d X = str(input()) N = len(X) stack_rem = 0 need_left = 0 pop_cnt = 0 for i in range(N): if X[i] == 'S': stack_rem += 1 elif stack_rem > 0: stack_rem -= 1 pop_cnt += 1 print(N-pop_cnt*2) resolve()
[ 7, 0, 13, 4, 13, 0, 13, 39, 0, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 17, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 17, 42, 2, 4, 13, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 64, 2 ], [ 58, 6 ], [ 61, 9 ], [ 13, 12 ], [ 65, 12 ], [ 12, 16 ], [ 59, 20 ], [ 59, 27 ], [ 59, 31 ], [ 62, 35 ], [ 59, 42 ], [ 62, 46 ], [ 59, 50 ], [ 62, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "X = input()\n\nstack_s = []\nout = []\n\nfor x in X:\n if x == \"S\":\n stack_s.append(\"S\")\n else:\n if len(stack_s) > 0:\n stack_s.pop()\n else:\n out.append(\"T\")\n\nwhile len(stack_s) > 0:\n out.append(stack_s.pop())\n\nprint(len(out))\n", "X = input()", "X", "input()", "input", "stack_s = []", "stack_s", "[]", "out = []", "out", "[]", "for x in X:\n if x == \"S\":\n stack_s.append(\"S\")\n else:\n if len(stack_s) > 0:\n stack_s.pop()\n else:\n out.append(\"T\")", "x", "X", "if x == \"S\":\n stack_s.append(\"S\")\n else:\n if len(stack_s) > 0:\n stack_s.pop()\n else:\n out.append(\"T\")", "x == \"S\"", "x", "\"S\"", "stack_s.append(\"S\")", "stack_s.append", "stack_s", "append", "\"S\"", "if len(stack_s) > 0:\n stack_s.pop()\n else:\n out.append(\"T\")", "len(stack_s) > 0", "len(stack_s)", "len", "stack_s", "0", "stack_s.pop()", "stack_s.pop", "stack_s", "pop", "out.append(\"T\")", "out.append", "out", "append", "\"T\"", "while len(stack_s) > 0:\n out.append(stack_s.pop())", "len(stack_s) > 0", "len(stack_s)", "len", "stack_s", "0", "out.append(stack_s.pop())", "out.append", "out", "append", "stack_s.pop()", "stack_s.pop", "stack_s", "pop", "print(len(out))", "print", "len(out)", "len", "out", "stack_s = []", "[]", "stack_s", "out = []", "[]", "out", "X = input()", "input()", "X" ]
X = input() stack_s = [] out = [] for x in X: if x == "S": stack_s.append("S") else: if len(stack_s) > 0: stack_s.pop() else: out.append("T") while len(stack_s) > 0: out.append(stack_s.pop()) print(len(out))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 0, 13, 4, 18, 4, 13, 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, 18, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 49, 4 ], [ 67, 11 ], [ 50, 15 ], [ 55, 18 ], [ 58, 21 ], [ 25, 24 ], [ 68, 24 ], [ 24, 28 ], [ 52, 31 ], [ 56, 35 ], [ 62, 35 ], [ 53, 35 ], [ 61, 38 ], [ 64, 41 ], [ 65, 46 ], [ 59, 46 ], [ 62, 47 ], [ 53, 47 ], [ 56, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "import sys\ninput = sys.stdin.readline\n\nS = input().rstrip()\ns_cnt =0\nt_cnt =0\n\nfor s in S:\n if s == 'S':\n s_cnt += 1\n else:\n if s_cnt >0:\n s_cnt -= 1\n else:\n t_cnt += 1\n \nprint(t_cnt + s_cnt)", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "S = input().rstrip()", "S", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "s_cnt =0", "s_cnt", "0", "t_cnt =0", "t_cnt", "0", "for s in S:\n if s == 'S':\n s_cnt += 1\n else:\n if s_cnt >0:\n s_cnt -= 1\n else:\n t_cnt += 1\n ", "s", "S", "if s == 'S':\n s_cnt += 1\n else:\n if s_cnt >0:\n s_cnt -= 1\n else:\n t_cnt += 1\n ", "s == 'S'", "s", "'S'", "s_cnt += 1", "s_cnt", "1", "if s_cnt >0:\n s_cnt -= 1\n else:\n t_cnt += 1\n ", "s_cnt >0", "s_cnt", "0", "s_cnt -= 1", "s_cnt", "1", "t_cnt += 1", "t_cnt", "1", "print(t_cnt + s_cnt)", "print", "t_cnt + s_cnt", "t_cnt", "s_cnt", "input = sys.stdin.readline", "sys.stdin.readline", "input", "s_cnt += 1", "1", "s_cnt", "s_cnt =0", "0", "s_cnt", "t_cnt =0", "0", "t_cnt", "s_cnt -= 1", "1", "s_cnt", "t_cnt += 1", "1", "t_cnt", "S = input().rstrip()", "input().rstrip()", "S" ]
import sys input = sys.stdin.readline S = input().rstrip() s_cnt =0 t_cnt =0 for s in S: if s == 'S': s_cnt += 1 else: if s_cnt >0: s_cnt -= 1 else: t_cnt += 1 print(t_cnt + s_cnt)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 2, 13, 17, 17, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 70, 2 ], [ 58, 6 ], [ 71, 9 ], [ 73, 11 ], [ 64, 14 ], [ 18, 17 ], [ 59, 21 ], [ 71, 28 ], [ 17, 29 ], [ 76, 32 ], [ 74, 37 ], [ 68, 37 ], [ 77, 37 ], [ 71, 41 ], [ 17, 42 ], [ 61, 45 ], [ 67, 48 ], [ 59, 53 ], [ 62, 56 ], [ 65, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "x=input()\nn=len(x)\n\nt=0\ncnt=0\nfor i in range(n-1,-1,-1):\n if x[i]=='T':\n t+=1\n elif t>0 and x[i]=='S':\n cnt+=1\n t-=1\n\nprint(n-2*cnt)", "x=input()", "x", "input()", "input", "n=len(x)", "n", "len(x)", "len", "x", "t=0", "t", "0", "cnt=0", "cnt", "0", "for i in range(n-1,-1,-1):\n if x[i]=='T':\n t+=1\n elif t>0 and x[i]=='S':\n cnt+=1\n t-=1", "i", "range(n-1,-1,-1)", "range", "n-1", "n", "1", "-1", "-1", "if x[i]=='T':\n t+=1\n elif t>0 and x[i]=='S':\n cnt+=1\n t-=1", "x[i]=='T'", "x[i]", "x", "i", "'T'", "t+=1", "t", "1", "elif t>0 and x[i]=='S':\n cnt+=1\n t-=1", "t>0 and x[i]=='S'", "t>0", "t", "0", "x[i]=='S'", "x[i]", "x", "i", "'S'", "cnt+=1", "cnt", "1", "t-=1", "t", "1", "print(n-2*cnt)", "print", "n-2*cnt", "n", "2*cnt", "2", "cnt", "n=len(x)", "len(x)", "n", "cnt+=1", "1", "cnt", "cnt=0", "0", "cnt", "t-=1", "1", "t", "x=input()", "input()", "x", "t=0", "0", "t", "t+=1", "1", "t" ]
x=input() n=len(x) t=0 cnt=0 for i in range(n-1,-1,-1): if x[i]=='T': t+=1 elif t>0 and x[i]=='S': cnt+=1 t-=1 print(n-2*cnt)
[ 7, 0, 13, 4, 13, 0, 13, 17, 28, 13, 13, 14, 2, 2, 13, 17, 13, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 4, 13, 2, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 33, 2 ], [ 36, 6 ], [ 10, 9 ], [ 34, 9 ], [ 9, 14 ], [ 37, 16 ], [ 43, 16 ], [ 40, 16 ], [ 39, 18 ], [ 9, 22 ], [ 42, 25 ], [ 43, 31 ], [ 40, 31 ], [ 37, 31 ], [ 33, 34 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ] ]
[ "x = input()\ncnt = 0\nfor x_ in x:\n if x_ == 'T' and cnt:\n cnt -= 1\n elif x_ == 'S':\n cnt += 1\nprint(2 * cnt)", "x = input()", "x", "input()", "input", "cnt = 0", "cnt", "0", "for x_ in x:\n if x_ == 'T' and cnt:\n cnt -= 1\n elif x_ == 'S':\n cnt += 1", "x_", "x", "if x_ == 'T' and cnt:\n cnt -= 1\n elif x_ == 'S':\n cnt += 1", "x_ == 'T' and cnt", "x_ == 'T'", "x_", "'T'", "cnt", "cnt -= 1", "cnt", "1", "elif x_ == 'S':\n cnt += 1", "x_ == 'S'", "x_", "'S'", "cnt += 1", "cnt", "1", "print(2 * cnt)", "print", "2 * cnt", "2", "cnt", "x = input()", "input()", "x", "cnt = 0", "0", "cnt", "cnt -= 1", "1", "cnt", "cnt += 1", "1", "cnt" ]
x = input() cnt = 0 for x_ in x: if x_ == 'T' and cnt: cnt -= 1 elif x_ == 'S': cnt += 1 print(2 * cnt)
[ 7, 15, 13, 15, 15, 12, 13, 12, 13, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 17, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 17, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 17, 4, 13, 4, 13, 13, 10, 39, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13 ]
[ [ 79, 12 ], [ 83, 16 ], [ 88, 18 ], [ 80, 21 ], [ 73, 23 ], [ 27, 26 ], [ 89, 29 ], [ 80, 33 ], [ 26, 34 ], [ 74, 38 ], [ 74, 45 ], [ 74, 49 ], [ 74, 55 ], [ 74, 60 ], [ 74, 64 ], [ 74, 71 ], [ 73, 74 ], [ 79, 80 ], [ 88, 89 ] ]
[ "import sys\nfrom collections import Counter\nfrom collections import deque\ndef input(): return sys.stdin.readline().strip()\ndef mp(): return map(int,input().split())\ndef lmp(): return list(map(int,input().split()))\n\nx=list(input())\nn=len(x)\nl=[]\nfor i in range(n):\n if x[i]==\"S\":\n l.append(\"S\")\n else:\n if len(l)==0:\n l.append(\"T\")\n elif l[-1]==\"S\":\n l.pop()\n else:\n l.append(\"T\")\nprint(len(l))", "import sys", "sys", "from collections import Counter", "from collections import deque", "def input(): return sys.stdin.readline().strip()", "input", "def mp(): return map(int,input().split())", "mp", "def lmp(): return list(map(int,input().split()))", "lmp", "x=list(input())", "x", "list(input())", "list", "input()", "input", "n=len(x)", "n", "len(x)", "len", "x", "l=[]", "l", "[]", "for i in range(n):\n if x[i]==\"S\":\n l.append(\"S\")\n else:\n if len(l)==0:\n l.append(\"T\")\n elif l[-1]==\"S\":\n l.pop()\n else:\n l.append(\"T\")", "i", "range(n)", "range", "n", "if x[i]==\"S\":\n l.append(\"S\")\n else:\n if len(l)==0:\n l.append(\"T\")\n elif l[-1]==\"S\":\n l.pop()\n else:\n l.append(\"T\")", "x[i]==\"S\"", "x[i]", "x", "i", "\"S\"", "l.append(\"S\")", "l.append", "l", "append", "\"S\"", "if len(l)==0:\n l.append(\"T\")\n elif l[-1]==\"S\":\n l.pop()\n else:\n l.append(\"T\")", "len(l)==0", "len(l)", "len", "l", "0", "l.append(\"T\")", "l.append", "l", "append", "\"T\"", "elif l[-1]==\"S\":\n l.pop()\n ", "l[-1]==\"S\"", "l[-1]", "l", "-1", "\"S\"", "l.pop()", "l.pop", "l", "pop", "l.append(\"T\")", "l.append", "l", "append", "\"T\"", "print(len(l))", "print", "len(l)", "len", "l", "l=[]", "[]", "l", "def mp(): return map(int,input().split())", "def mp(): return map(int,input().split())", "mp", "x=list(input())", "list(input())", "x", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "def lmp(): return list(map(int,input().split()))", "def lmp(): return list(map(int,input().split()))", "lmp", "n=len(x)", "len(x)", "n" ]
import sys from collections import Counter from collections import deque def input(): return sys.stdin.readline().strip() def mp(): return map(int,input().split()) def lmp(): return list(map(int,input().split())) x=list(input()) n=len(x) l=[] for i in range(n): if x[i]=="S": l.append("S") else: if len(l)==0: l.append("T") elif l[-1]=="S": l.pop() else: l.append("T") print(len(l))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 4, 13, 13, 17, 14, 2, 18, 13, 17, 17, 4, 18, 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, 39, 13 ]
[ [ 70, 2 ], [ 67, 6 ], [ 71, 9 ], [ 73, 11 ], [ 15, 14 ], [ 68, 17 ], [ 71, 21 ], [ 14, 22 ], [ 74, 26 ], [ 71, 29 ], [ 14, 30 ], [ 74, 35 ], [ 74, 40 ], [ 74, 45 ], [ 74, 49 ], [ 71, 52 ], [ 14, 53 ], [ 74, 56 ], [ 71, 59 ], [ 14, 60 ], [ 74, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ] ]
[ "x = input()\nn = len(x)\nans = []\nfor i in range(n):\n if x[i] == 'S':\n ans.append(x[i])\n else:\n if len(ans) > 0:\n if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x[i])\n else:\n ans.append(x[i])\n # print(ans)\n\nprint(len(ans))", "x = input()", "x", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "ans = []", "ans", "[]", "for i in range(n):\n if x[i] == 'S':\n ans.append(x[i])\n else:\n if len(ans) > 0:\n if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x[i])\n else:\n ans.append(x[i])\n # print(ans)", "i", "range(n)", "range", "n", "if x[i] == 'S':\n ans.append(x[i])\n else:\n if len(ans) > 0:\n if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x[i])\n else:\n ans.append(x[i])\n # print(ans)", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "ans.append(x[i])", "ans.append", "ans", "append", "x[i]", "x", "i", "if len(ans) > 0:\n if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x[i])\n else:\n ans.append(x[i])\n # print(ans)", "len(ans) > 0", "len(ans)", "len", "ans", "0", "if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x[i])\n ", "ans[-1] == 'S'", "ans[-1]", "ans", "-1", "'S'", "ans.pop()", "ans.pop", "ans", "pop", "ans.append(x[i])", "ans.append", "ans", "append", "x[i]", "x", "i", "ans.append(x[i])", "ans.append", "ans", "append", "x[i]", "x", "i", "print(len(ans))", "print", "len(ans)", "len", "ans", "n = len(x)", "len(x)", "n", "x = input()", "input()", "x", "ans = []", "[]", "ans" ]
x = input() n = len(x) ans = [] for i in range(n): if x[i] == 'S': ans.append(x[i]) else: if len(ans) > 0: if ans[-1] == 'S': ans.pop() else: ans.append(x[i]) else: ans.append(x[i]) # print(ans) print(len(ans))
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 17, 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, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 11, 10 ], [ 14, 13 ], [ 4, 13 ], [ 13, 17 ], [ 8, 21 ], [ 30, 21 ], [ 27, 21 ], [ 25, 24 ], [ 28, 27 ], [ 31, 30 ], [ 24, 35 ], [ 10, 35 ], [ 45, 42 ] ]
[ "def main():\n X = input()\n cs, ct = 0, 0\n for x in X:\n if x == 'T':\n if cs == 0:\n ct += 1\n else:\n cs -= 1\n else:\n cs += 1\n print(ct * 2)\nif __name__ == '__main__':\n main()", "def main():\n X = input()\n cs, ct = 0, 0\n for x in X:\n if x == 'T':\n if cs == 0:\n ct += 1\n else:\n cs -= 1\n else:\n cs += 1\n print(ct * 2)", "main", "X = input()", "X", "input()", "input", "cs, ct = 0, 0", "cs", "0", "ct", "0", "for x in X:\n if x == 'T':\n if cs == 0:\n ct += 1\n else:\n cs -= 1\n else:\n cs += 1\n ", "x", "X", "if x == 'T':\n if cs == 0:\n ct += 1\n else:\n cs -= 1\n else:\n cs += 1\n ", "x == 'T'", "x", "'T'", "if cs == 0:\n ct += 1\n else:\n cs -= 1\n ", "cs == 0", "cs", "0", "ct += 1", "ct", "1", "cs -= 1", "cs", "1", "cs += 1", "cs", "1", "print(ct * 2)", "print", "ct * 2", "ct", "2", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n X = input()\n cs, ct = 0, 0\n for x in X:\n if x == 'T':\n if cs == 0:\n ct += 1\n else:\n cs -= 1\n else:\n cs += 1\n print(ct * 2)", "def main():\n X = input()\n cs, ct = 0, 0\n for x in X:\n if x == 'T':\n if cs == 0:\n ct += 1\n else:\n cs -= 1\n else:\n cs += 1\n print(ct * 2)", "main" ]
def main(): X = input() cs, ct = 0, 0 for x in X: if x == 'T': if cs == 0: ct += 1 else: cs -= 1 else: cs += 1 print(ct * 2) if __name__ == '__main__': main()
[ 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, 4, 13, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 41, 2 ], [ 50, 6 ], [ 53, 9 ], [ 13, 12 ], [ 42, 12 ], [ 12, 16 ], [ 47, 19 ], [ 51, 23 ], [ 57, 23 ], [ 48, 23 ], [ 56, 26 ], [ 44, 29 ], [ 42, 36 ], [ 45, 38 ], [ 54, 38 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "s=input()\nstack=0\nx=0#消したペア数\nfor c in s:\n if c=='S':\n stack+=1\n else:\n if stack>0:\n stack-=1\n x+=1\nprint(len(s)-x*2)", "s=input()", "s", "input()", "input", "stack=0", "stack", "0", "x=0", "x", "0", "for c in s:\n if c=='S':\n stack+=1\n else:\n if stack>0:\n stack-=1\n x+=1", "c", "s", "if c=='S':\n stack+=1\n else:\n if stack>0:\n stack-=1\n x+=1", "c=='S'", "c", "'S'", "stack+=1", "stack", "1", "if stack>0:\n stack-=1\n x+=1", "stack>0", "stack", "0", "stack-=1", "stack", "1", "x+=1", "x", "1", "print(len(s)-x*2)", "print", "len(s)-x*2", "len(s)", "len", "s", "x*2", "x", "2", "s=input()", "input()", "s", "x+=1", "1", "x", "stack+=1", "1", "stack", "stack=0", "0", "stack", "x=0", "0", "x", "stack-=1", "1", "stack" ]
s=input() stack=0 x=0#消したペア数 for c in s: if c=='S': stack+=1 else: if stack>0: stack-=1 x+=1 print(len(s)-x*2)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 14, 13, 0, 13, 17, 0, 13, 17, 14, 40, 13, 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, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 75, 6 ], [ 52, 9 ], [ 60, 11 ], [ 57, 14 ], [ 18, 17 ], [ 52, 17 ], [ 17, 21 ], [ 54, 26 ], [ 72, 29 ], [ 58, 33 ], [ 70, 33 ], [ 55, 33 ], [ 69, 35 ], [ 73, 39 ], [ 61, 39 ], [ 67, 39 ], [ 66, 42 ], [ 63, 45 ], [ 64, 49 ], [ 76, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "x = input()\nans = len(x)\ncs = 0\nT = False\n\nfor i in x:\n if i == 'S':\n if T:\n T = False\n cs += 1\n else:\n if not T:\n T = True\n if cs > 0:\n cs -= 1\n ans -= 2\nprint(ans)", "x = input()", "x", "input()", "input", "ans = len(x)", "ans", "len(x)", "len", "x", "cs = 0", "cs", "0", "T = False", "T", "False", "for i in x:\n if i == 'S':\n if T:\n T = False\n cs += 1\n else:\n if not T:\n T = True\n if cs > 0:\n cs -= 1\n ans -= 2", "i", "x", "if i == 'S':\n if T:\n T = False\n cs += 1\n else:\n if not T:\n T = True\n if cs > 0:\n cs -= 1\n ans -= 2", "i == 'S'", "i", "'S'", "if T:\n T = False\n ", "T", "T = False", "T", "False", "cs += 1", "cs", "1", "if not T:\n T = True\n ", "not T", "T", "T = True", "T", "True", "if cs > 0:\n cs -= 1\n ans -= 2", "cs > 0", "cs", "0", "cs -= 1", "cs", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "x = input()", "input()", "x", "T = False", "False", "T", "T = False", "False", "T", "cs = 0", "0", "cs", "ans -= 2", "2", "ans", "cs -= 1", "1", "cs", "T = True", "True", "T", "cs += 1", "1", "cs", "ans = len(x)", "len(x)", "ans" ]
x = input() ans = len(x) cs = 0 T = False for i in x: if i == 'S': if T: T = False cs += 1 else: if not T: T = True if cs > 0: cs -= 1 ans -= 2 print(ans)
[ 7, 12, 13, 0, 13, 39, 0, 13, 18, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 13, 0, 13, 17, 4, 18, 13, 13, 13, 0, 13, 18, 13, 13, 0, 13, 17, 4, 18, 13, 13, 13, 29, 13, 23, 13, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 14, 2, 18, 13, 17, 17, 0, 13, 2, 39, 17, 13, 14, 2, 18, 13, 17, 17, 0, 13, 39, 17, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 17, 0, 13, 2, 17, 4, 13, 2, 13, 18, 13, 13, 18, 13, 2, 13, 17, 0, 13, 4, 13, 17, 2, 2, 13, 18, 13, 13, 18, 13, 2, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 8, 7 ], [ 51, 9 ], [ 13, 12 ], [ 16, 15 ], [ 51, 20 ], [ 51, 24 ], [ 15, 25 ], [ 7, 26 ], [ 36, 26 ], [ 29, 28 ], [ 4, 32 ], [ 12, 34 ], [ 41, 34 ], [ 28, 34 ], [ 37, 36 ], [ 51, 38 ], [ 15, 39 ], [ 42, 41 ], [ 4, 45 ], [ 41, 47 ], [ 28, 47 ], [ 12, 47 ], [ 4, 49 ], [ 51, 51 ], [ 56, 55 ], [ 60, 59 ], [ 145, 61 ], [ 55, 62 ], [ 55, 66 ], [ 71, 70 ], [ 59, 74 ], [ 55, 78 ], [ 83, 82 ], [ 87, 86 ], [ 55, 89 ], [ 92, 91 ], [ 95, 94 ], [ 82, 100 ], [ 70, 100 ], [ 59, 100 ], [ 104, 103 ], [ 91, 109 ], [ 119, 109 ], [ 82, 111 ], [ 70, 111 ], [ 59, 111 ], [ 94, 112 ], [ 82, 114 ], [ 70, 114 ], [ 59, 114 ], [ 94, 116 ], [ 120, 119 ], [ 91, 125 ], [ 119, 125 ], [ 82, 127 ], [ 70, 127 ], [ 59, 127 ], [ 94, 128 ], [ 82, 130 ], [ 70, 130 ], [ 59, 130 ], [ 94, 132 ], [ 103, 136 ], [ 86, 136 ], [ 148, 142 ] ]
[ "def runlength(S):\n A = []\n tmp = S[0]\n cnt = 0\n for i in range(len(S)):\n if S[i] == tmp:\n cnt += 1\n else:\n A.append(cnt)\n tmp = S[i]\n cnt = 1\n else:\n A.append(cnt)\n return A\n\ndef main():\n X = input()\n Y = runlength(X)\n if X[0] == 'T':\n Y = [0] + Y\n \n if X[-1] == 'S':\n Y += [0]\n\n ans = len(X)\n amari = 0\n for i in range(0,len(Y),2):\n ans -= 2 * min(amari + Y[i], Y[i+1])\n amari = max(0, amari + Y[i] - Y[i+1])\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "def runlength(S):\n A = []\n tmp = S[0]\n cnt = 0\n for i in range(len(S)):\n if S[i] == tmp:\n cnt += 1\n else:\n A.append(cnt)\n tmp = S[i]\n cnt = 1\n else:\n A.append(cnt)\n return A", "runlength", "A = []", "A", "[]", "tmp = S[0]", "tmp", "S[0]", "S", "0", "cnt = 0", "cnt", "0", "for i in range(len(S)):\n if S[i] == tmp:\n cnt += 1\n else:\n A.append(cnt)\n tmp = S[i]\n cnt = 1\n else:\n A.append(cnt)\n ", "i", "range(len(S))", "range", "len(S)", "len", "S", "if S[i] == tmp:\n cnt += 1\n else:\n A.append(cnt)\n tmp = S[i]\n cnt = 1\n ", "S[i] == tmp", "S[i]", "S", "i", "tmp", "cnt += 1", "cnt", "1", "A.append(cnt)", "A.append", "A", "append", "cnt", "tmp = S[i]", "tmp", "S[i]", "S", "i", "cnt = 1", "cnt", "1", "A.append(cnt)", "A.append", "A", "append", "cnt", "return A", "A", "S", "S", "def main():\n X = input()\n Y = runlength(X)\n if X[0] == 'T':\n Y = [0] + Y\n \n if X[-1] == 'S':\n Y += [0]\n\n ans = len(X)\n amari = 0\n for i in range(0,len(Y),2):\n ans -= 2 * min(amari + Y[i], Y[i+1])\n amari = max(0, amari + Y[i] - Y[i+1])\n\n print(ans)", "main", "X = input()", "X", "input()", "input", "Y = runlength(X)", "Y", "runlength(X)", "runlength", "X", "if X[0] == 'T':\n Y = [0] + Y\n \n ", "X[0] == 'T'", "X[0]", "X", "0", "'T'", "Y = [0] + Y", "Y", "[0] + Y", "[0]", "0", "Y", "if X[-1] == 'S':\n Y += [0]\n\n ", "X[-1] == 'S'", "X[-1]", "X", "-1", "'S'", "Y += [0]", "Y", "[0]", "0", "ans = len(X)", "ans", "len(X)", "len", "X", "amari = 0", "amari", "0", "for i in range(0,len(Y),2):\n ans -= 2 * min(amari + Y[i], Y[i+1])\n amari = max(0, amari + Y[i] - Y[i+1])\n\n ", "i", "range(0,len(Y),2)", "range", "0", "len(Y)", "len", "Y", "2", "ans -= 2 * min(amari + Y[i], Y[i+1])", "ans", "2 * min(amari + Y[i], Y[i+1])", "2", "min(amari + Y[i], Y[i+1])", "min", "amari + Y[i]", "amari", "Y[i]", "Y", "i", "Y[i+1]", "Y", "i+1", "i", "1", "amari = max(0, amari + Y[i] - Y[i+1])", "amari", "max(0, amari + Y[i] - Y[i+1])", "max", "0", "amari + Y[i] - Y[i+1]", "amari + Y[i]", "amari", "Y[i]", "Y", "i", "Y[i+1]", "Y", "i+1", "i", "1", "print(ans)", "print", "ans", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def runlength(S):\n A = []\n tmp = S[0]\n cnt = 0\n for i in range(len(S)):\n if S[i] == tmp:\n cnt += 1\n else:\n A.append(cnt)\n tmp = S[i]\n cnt = 1\n else:\n A.append(cnt)\n return A", "def runlength(S):\n A = []\n tmp = S[0]\n cnt = 0\n for i in range(len(S)):\n if S[i] == tmp:\n cnt += 1\n else:\n A.append(cnt)\n tmp = S[i]\n cnt = 1\n else:\n A.append(cnt)\n return A", "runlength", "def main():\n X = input()\n Y = runlength(X)\n if X[0] == 'T':\n Y = [0] + Y\n \n if X[-1] == 'S':\n Y += [0]\n\n ans = len(X)\n amari = 0\n for i in range(0,len(Y),2):\n ans -= 2 * min(amari + Y[i], Y[i+1])\n amari = max(0, amari + Y[i] - Y[i+1])\n\n print(ans)", "def main():\n X = input()\n Y = runlength(X)\n if X[0] == 'T':\n Y = [0] + Y\n \n if X[-1] == 'S':\n Y += [0]\n\n ans = len(X)\n amari = 0\n for i in range(0,len(Y),2):\n ans -= 2 * min(amari + Y[i], Y[i+1])\n amari = max(0, amari + Y[i] - Y[i+1])\n\n print(ans)", "main" ]
def runlength(S): A = [] tmp = S[0] cnt = 0 for i in range(len(S)): if S[i] == tmp: cnt += 1 else: A.append(cnt) tmp = S[i] cnt = 1 else: A.append(cnt) return A def main(): X = input() Y = runlength(X) if X[0] == 'T': Y = [0] + Y if X[-1] == 'S': Y += [0] ans = len(X) amari = 0 for i in range(0,len(Y),2): ans -= 2 * min(amari + Y[i], Y[i+1]) amari = max(0, amari + Y[i] - Y[i+1]) print(ans) if __name__ == "__main__": main()
[ 7, 12, 13, 15, 13, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 13, 2, 17, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 9, 8 ], [ 6, 10 ], [ 13, 12 ], [ 16, 15 ], [ 19, 18 ], [ 8, 18 ], [ 18, 22 ], [ 26, 25 ], [ 29, 28 ], [ 32, 31 ], [ 15, 34 ], [ 31, 34 ], [ 28, 35 ], [ 25, 35 ], [ 12, 35 ], [ 28, 39 ], [ 25, 39 ], [ 12, 39 ], [ 31, 42 ], [ 15, 42 ], [ 51, 48 ] ]
[ "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n x = input() \n cnt = 0\n t = 0\n for i in x:\n if i == 'S':\n cnt += 1\n else:\n cnt -= 1\n t = min(t, cnt)\n print(cnt-2*t)\n\n\n\nif __name__ == '__main__':\n main()", "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n x = input() \n cnt = 0\n t = 0\n for i in x:\n if i == 'S':\n cnt += 1\n else:\n cnt -= 1\n t = min(t, cnt)\n print(cnt-2*t)", "main", "import sys", "sys", "def input(): return sys.stdin.readline().rstrip()\n\n ", "input", "x = input()", "x", "input()", "input", "cnt = 0", "cnt", "0", "t = 0", "t", "0", "for i in x:\n if i == 'S':\n cnt += 1\n else:\n cnt -= 1\n t = min(t, cnt)\n ", "i", "x", "if i == 'S':\n cnt += 1\n else:\n cnt -= 1\n ", "i == 'S'", "i", "'S'", "cnt += 1", "cnt", "1", "cnt -= 1", "cnt", "1", "t = min(t, cnt)", "t", "min(t, cnt)", "min", "t", "cnt", "print(cnt-2*t)", "print", "cnt-2*t", "cnt", "2*t", "2", "t", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n x = input() \n cnt = 0\n t = 0\n for i in x:\n if i == 'S':\n cnt += 1\n else:\n cnt -= 1\n t = min(t, cnt)\n print(cnt-2*t)", "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n x = input() \n cnt = 0\n t = 0\n for i in x:\n if i == 'S':\n cnt += 1\n else:\n cnt -= 1\n t = min(t, cnt)\n print(cnt-2*t)", "main" ]
def main(): import sys def input(): return sys.stdin.readline().rstrip() x = input() cnt = 0 t = 0 for i in x: if i == 'S': cnt += 1 else: cnt -= 1 t = min(t, cnt) print(cnt-2*t) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 17, 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, 14, 40, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 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, 17, 13 ]
[ [ 62, 2 ], [ 59, 7 ], [ 65, 10 ], [ 53, 13 ], [ 17, 16 ], [ 63, 16 ], [ 16, 20 ], [ 68, 23 ], [ 16, 27 ], [ 71, 30 ], [ 72, 34 ], [ 66, 34 ], [ 75, 34 ], [ 69, 35 ], [ 60, 35 ], [ 57, 35 ], [ 77, 37 ], [ 56, 40 ], [ 74, 43 ], [ 63, 50 ], [ 78, 51 ], [ 54, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ] ]
[ "X = input()\n\"\"\"\nTの前にSがどれだけあるか?\nTSSTTTSS\n\"\"\"\ns_cnt = 0\nt_cnt = 0\ncnt = 0\nfor s in X:\n if s == \"S\":\n s_cnt += 1\n if s == \"T\":\n t_cnt += 1\n if t_cnt <= s_cnt:\n cnt += 2\n else:\n s_cnt = 0\n t_cnt = 0\n\n\nprint(len(X) - cnt)", "X = input()", "X", "input()", "input", "\"\"\"\nTの前にSがどれだけあるか?\nTSSTTTSS\n\"\"\"", "s_cnt = 0", "s_cnt", "0", "t_cnt = 0", "t_cnt", "0", "cnt = 0", "cnt", "0", "for s in X:\n if s == \"S\":\n s_cnt += 1\n if s == \"T\":\n t_cnt += 1\n if t_cnt <= s_cnt:\n cnt += 2\n else:\n s_cnt = 0\n t_cnt = 0", "s", "X", "if s == \"S\":\n s_cnt += 1\n ", "s == \"S\"", "s", "\"S\"", "s_cnt += 1", "s_cnt", "1", "if s == \"T\":\n t_cnt += 1\n if t_cnt <= s_cnt:\n cnt += 2\n else:\n s_cnt = 0\n t_cnt = 0", "s == \"T\"", "s", "\"T\"", "t_cnt += 1", "t_cnt", "1", "if t_cnt <= s_cnt:\n cnt += 2\n else:\n s_cnt = 0\n t_cnt = 0", "t_cnt <= s_cnt", "t_cnt", "s_cnt", "cnt += 2", "cnt", "2", "s_cnt = 0", "s_cnt", "0", "t_cnt = 0", "t_cnt", "0", "print(len(X) - cnt)", "print", "len(X) - cnt", "len(X)", "len", "X", "cnt", "cnt = 0", "0", "cnt", "s_cnt = 0", "0", "s_cnt", "s_cnt = 0", "0", "s_cnt", "X = input()", "input()", "X", "t_cnt = 0", "0", "t_cnt", "s_cnt += 1", "1", "s_cnt", "t_cnt += 1", "1", "t_cnt", "t_cnt = 0", "0", "t_cnt", "cnt += 2", "2", "cnt" ]
X = input() """ Tの前にSがどれだけあるか? TSSTTTSS """ s_cnt = 0 t_cnt = 0 cnt = 0 for s in X: if s == "S": s_cnt += 1 if s == "T": t_cnt += 1 if t_cnt <= s_cnt: cnt += 2 else: s_cnt = 0 t_cnt = 0 print(len(X) - cnt)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 4, 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, 10, 17, 13 ]
[ [ 73, 2 ], [ 58, 6 ], [ 74, 9 ], [ 61, 11 ], [ 82, 14 ], [ 85, 16 ], [ 20, 19 ], [ 59, 22 ], [ 74, 26 ], [ 19, 27 ], [ 79, 30 ], [ 64, 33 ], [ 83, 38 ], [ 77, 38 ], [ 80, 38 ], [ 65, 41 ], [ 86, 41 ], [ 68, 41 ], [ 76, 44 ], [ 67, 47 ], [ 70, 50 ], [ 59, 55 ], [ 71, 56 ], [ 62, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ] ]
[ "X = input()\nN = len(X)\nc = 0\ns, t = 0, 0\nfor k in range(N):\n if X[k] == \"S\":\n s += 1\n else:\n t += 1\n if s > 0 and t > 0:\n s -= 1\n t -= 1\n c += 2\nprint(N-c)", "X = input()", "X", "input()", "input", "N = len(X)", "N", "len(X)", "len", "X", "c = 0", "c", "0", "s, t = 0, 0", "s", "0", "t", "0", "for k in range(N):\n if X[k] == \"S\":\n s += 1\n else:\n t += 1\n if s > 0 and t > 0:\n s -= 1\n t -= 1\n c += 2", "k", "range(N)", "range", "N", "if X[k] == \"S\":\n s += 1\n else:\n t += 1\n if s > 0 and t > 0:\n s -= 1\n t -= 1\n c += 2", "X[k] == \"S\"", "X[k]", "X", "k", "\"S\"", "s += 1", "s", "1", "t += 1", "t", "1", "if s > 0 and t > 0:\n s -= 1\n t -= 1\n c += 2", "s > 0 and t > 0", "s > 0", "s", "0", "t > 0", "t", "0", "s -= 1", "s", "1", "t -= 1", "t", "1", "c += 2", "c", "2", "print(N-c)", "print", "N-c", "N", "c", "N = len(X)", "len(X)", "N", "c = 0", "0", "c", "t += 1", "1", "t", "t -= 1", "1", "t", "c += 2", "2", "c", "X = input()", "input()", "X", "s -= 1", "1", "s", "s += 1", "1", "s", "s, t = 0, 0", "0", "s", "t = 0, 0", "0", "t" ]
X = input() N = len(X) c = 0 s, t = 0, 0 for k in range(N): if X[k] == "S": s += 1 else: t += 1 if s > 0 and t > 0: s -= 1 t -= 1 c += 2 print(N-c)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 14, 40, 13, 17, 0, 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 ]
[ [ 46, 2 ], [ 55, 8 ], [ 52, 11 ], [ 15, 14 ], [ 47, 14 ], [ 14, 18 ], [ 43, 21 ], [ 14, 25 ], [ 44, 29 ], [ 56, 29 ], [ 59, 29 ], [ 58, 32 ], [ 49, 35 ], [ 50, 40 ], [ 53, 40 ], [ 59, 41 ], [ 44, 41 ], [ 56, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "x = str(input())\nz = 0\nt = 0\nfor xi in x:\n if xi == \"S\":\n z += 1\n if xi == \"T\":\n if z >= 1:\n z -= 1\n else:\n t += 1\nprint(t+z)", "x = str(input())", "x", "str(input())", "str", "input()", "input", "z = 0", "z", "0", "t = 0", "t", "0", "for xi in x:\n if xi == \"S\":\n z += 1\n if xi == \"T\":\n if z >= 1:\n z -= 1\n else:\n t += 1", "xi", "x", "if xi == \"S\":\n z += 1\n ", "xi == \"S\"", "xi", "\"S\"", "z += 1", "z", "1", "if xi == \"T\":\n if z >= 1:\n z -= 1\n else:\n t += 1", "xi == \"T\"", "xi", "\"T\"", "if z >= 1:\n z -= 1\n else:\n t += 1", "z >= 1", "z", "1", "z -= 1", "z", "1", "t += 1", "t", "1", "print(t+z)", "print", "t+z", "t", "z", "z += 1", "1", "z", "x = str(input())", "str(input())", "x", "t += 1", "1", "t", "t = 0", "0", "t", "z = 0", "0", "z", "z -= 1", "1", "z" ]
x = str(input()) z = 0 t = 0 for xi in x: if xi == "S": z += 1 if xi == "T": if z >= 1: z -= 1 else: t += 1 print(t+z)
[ 7, 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, 2, 4, 13, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 55, 2 ], [ 58, 6 ], [ 56, 9 ], [ 52, 11 ], [ 15, 14 ], [ 56, 14 ], [ 14, 18 ], [ 53, 22 ], [ 14, 24 ], [ 53, 30 ], [ 53, 34 ], [ 53, 39 ], [ 14, 41 ], [ 53, 44 ], [ 53, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "X = input()\nN = len(X)\nstack = []\nfor x in X:\n if x == \"S\":\n stack.append(x)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(x)\n else:\n stack.pop()\n \nprint(len(stack))", "X = input()", "X", "input()", "input", "N = len(X)", "N", "len(X)", "len", "X", "stack = []", "stack", "[]", "for x in X:\n if x == \"S\":\n stack.append(x)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(x)\n else:\n stack.pop()\n ", "x", "X", "if x == \"S\":\n stack.append(x)\n else:\n if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(x)\n else:\n stack.pop()\n ", "x == \"S\"", "x", "\"S\"", "stack.append(x)", "stack.append", "stack", "append", "x", "if len(stack) == 0 or stack[-1] == \"T\":\n stack.append(x)\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(x)", "stack.append", "stack", "append", "x", "stack.pop()", "stack.pop", "stack", "pop", "print(len(stack))", "print", "len(stack)", "len", "stack", "stack = []", "[]", "stack", "X = input()", "input()", "X", "N = len(X)", "len(X)", "N" ]
X = input() N = len(X) stack = [] for x in X: if x == "S": stack.append(x) else: if len(stack) == 0 or stack[-1] == "T": stack.append(x) else: stack.pop() print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 2, 13, 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 ]
[ [ 41, 2 ], [ 38, 6 ], [ 10, 9 ], [ 42, 9 ], [ 39, 14 ], [ 39, 17 ], [ 9, 21 ], [ 39, 25 ], [ 39, 29 ], [ 9, 31 ], [ 39, 36 ], [ 38, 39 ], [ 41, 42 ] ]
[ "X = input()\nstack = []\nfor x in X:\n if stack and stack[-1] == \"S\" and x == \"T\":\n stack.pop()\n else:\n stack.append(x)\nprint(len(stack))", "X = input()", "X", "input()", "input", "stack = []", "stack", "[]", "for x in X:\n if stack and stack[-1] == \"S\" and x == \"T\":\n stack.pop()\n else:\n stack.append(x)", "x", "X", "if stack and stack[-1] == \"S\" and x == \"T\":\n stack.pop()\n else:\n stack.append(x)", "stack and stack[-1] == \"S\" and x == \"T\"", "stack and stack[-1] == \"S\"", "stack", "stack[-1] == \"S\"", "stack[-1]", "stack", "-1", "\"S\"", "x == \"T\"", "x", "\"T\"", "stack.pop()", "stack.pop", "stack", "pop", "stack.append(x)", "stack.append", "stack", "append", "x", "print(len(stack))", "print", "len(stack)", "len", "stack", "stack = []", "[]", "stack", "X = input()", "input()", "X" ]
X = input() stack = [] for x in X: if stack and stack[-1] == "S" and x == "T": stack.pop() else: stack.append(x) print(len(stack))
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 15, 0, 13, 4, 13, 39, 0, 13, 18, 13, 13, 0, 13, 18, 13, 13, 28, 13, 13, 14, 2, 13, 17, 4, 13, 13, 14, 2, 2, 4, 13, 13, 17, 2, 18, 13, 17, 17, 0, 13, 17, 4, 13, 4, 13, 13, 4, 13, 13, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 4, 11 ], [ 15, 14 ], [ 20, 19 ], [ 14, 21 ], [ 25, 24 ], [ 14, 26 ], [ 30, 29 ], [ 4, 29 ], [ 29, 33 ], [ 19, 36 ], [ 29, 37 ], [ 14, 43 ], [ 14, 47 ], [ 52, 51 ], [ 24, 54 ], [ 19, 56 ], [ 29, 57 ], [ 51, 60 ], [ 8, 60 ], [ 65, 62 ] ]
[ "def main():\n X = input()\n result = len(X)\n from collections import deque\n d = deque([])\n append = d.appendleft\n pop = d.popleft\n for x in X:\n if x == \"S\":\n append(x)\n else:\n if len(d) > 0 and d[0] == \"S\":\n result -= 2\n pop()\n else:\n append(x)\n print(result)\nmain()", "def main():\n X = input()\n result = len(X)\n from collections import deque\n d = deque([])\n append = d.appendleft\n pop = d.popleft\n for x in X:\n if x == \"S\":\n append(x)\n else:\n if len(d) > 0 and d[0] == \"S\":\n result -= 2\n pop()\n else:\n append(x)\n print(result)", "main", "X = input()", "X", "input()", "input", "result = len(X)", "result", "len(X)", "len", "X", "from collections import deque", "d = deque([])", "d", "deque([])", "deque", "[]", "append = d.appendleft", "append", "d.appendleft", "d", "appendleft", "pop = d.popleft", "pop", "d.popleft", "d", "popleft", "for x in X:\n if x == \"S\":\n append(x)\n else:\n if len(d) > 0 and d[0] == \"S\":\n result -= 2\n pop()\n else:\n append(x)\n ", "x", "X", "if x == \"S\":\n append(x)\n else:\n if len(d) > 0 and d[0] == \"S\":\n result -= 2\n pop()\n else:\n append(x)\n ", "x == \"S\"", "x", "\"S\"", "append(x)", "append", "x", "if len(d) > 0 and d[0] == \"S\":\n result -= 2\n pop()\n else:\n append(x)\n ", "len(d) > 0 and d[0] == \"S\"", "len(d) > 0", "len(d)", "len", "d", "0", "d[0] == \"S\"", "d[0]", "d", "0", "\"S\"", "result -= 2", "result", "2", "pop()", "pop", "append(x)", "append", "x", "print(result)", "print", "result", "main()", "main", "def main():\n X = input()\n result = len(X)\n from collections import deque\n d = deque([])\n append = d.appendleft\n pop = d.popleft\n for x in X:\n if x == \"S\":\n append(x)\n else:\n if len(d) > 0 and d[0] == \"S\":\n result -= 2\n pop()\n else:\n append(x)\n print(result)", "def main():\n X = input()\n result = len(X)\n from collections import deque\n d = deque([])\n append = d.appendleft\n pop = d.popleft\n for x in X:\n if x == \"S\":\n append(x)\n else:\n if len(d) > 0 and d[0] == \"S\":\n result -= 2\n pop()\n else:\n append(x)\n print(result)", "main" ]
def main(): X = input() result = len(X) from collections import deque d = deque([]) append = d.appendleft pop = d.popleft for x in X: if x == "S": append(x) else: if len(d) > 0 and d[0] == "S": result -= 2 pop() else: append(x) print(result) main()
[ 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, 4, 13, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 56, 2 ], [ 41, 6 ], [ 50, 9 ], [ 13, 12 ], [ 57, 12 ], [ 12, 16 ], [ 53, 19 ], [ 42, 23 ], [ 48, 23 ], [ 54, 23 ], [ 44, 26 ], [ 47, 29 ], [ 57, 36 ], [ 45, 39 ], [ 51, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "X = input()\ns_cnt = 0\nans = 0\nfor s in X:\n if s=='S':\n s_cnt += 1\n else:\n if s_cnt > 0:\n ans += 1\n s_cnt -= 1\n\nprint(len(X) - 2*ans)", "X = input()", "X", "input()", "input", "s_cnt = 0", "s_cnt", "0", "ans = 0", "ans", "0", "for s in X:\n if s=='S':\n s_cnt += 1\n else:\n if s_cnt > 0:\n ans += 1\n s_cnt -= 1", "s", "X", "if s=='S':\n s_cnt += 1\n else:\n if s_cnt > 0:\n ans += 1\n s_cnt -= 1", "s=='S'", "s", "'S'", "s_cnt += 1", "s_cnt", "1", "if s_cnt > 0:\n ans += 1\n s_cnt -= 1", "s_cnt > 0", "s_cnt", "0", "ans += 1", "ans", "1", "s_cnt -= 1", "s_cnt", "1", "print(len(X) - 2*ans)", "print", "len(X) - 2*ans", "len(X)", "len", "X", "2*ans", "2", "ans", "s_cnt = 0", "0", "s_cnt", "ans += 1", "1", "ans", "s_cnt -= 1", "1", "s_cnt", "ans = 0", "0", "ans", "s_cnt += 1", "1", "s_cnt", "X = input()", "input()", "X" ]
X = input() s_cnt = 0 ans = 0 for s in X: if s=='S': s_cnt += 1 else: if s_cnt > 0: ans += 1 s_cnt -= 1 print(len(X) - 2*ans)
[ 7, 15, 13, 4, 18, 13, 13, 2, 2, 17, 17, 17, 12, 13, 12, 13, 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, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 18, 17 ], [ 73, 21 ], [ 24, 23 ], [ 27, 26 ], [ 30, 29 ], [ 17, 34 ], [ 17, 38 ], [ 29, 39 ], [ 43, 42 ], [ 17, 48 ], [ 29, 49 ], [ 23, 52 ], [ 58, 52 ], [ 42, 52 ], [ 56, 55 ], [ 59, 58 ], [ 17, 65 ], [ 55, 67 ], [ 26, 67 ], [ 76, 70 ] ]
[ "import sys\nsys.setrecursionlimit(10 ** 5 + 10)\n\n\ndef input(): return sys.stdin.readline().strip()\n\n\ndef resolve():\n\n X = str(input())\n stack = 0\n pop = 0\n for i in range(len(X)):\n if X[i] == 'S':\n stack += 1\n elif X[i] == 'T' and stack > 0:\n pop += 1\n stack -= 1\n print(len(X)-pop*2)\n\nresolve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 5 + 10)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 5 + 10", "10 ** 5", "10", "5", "10", "def input(): return sys.stdin.readline().strip()", "input", "def resolve():\n\n X = str(input())\n stack = 0\n pop = 0\n for i in range(len(X)):\n if X[i] == 'S':\n stack += 1\n elif X[i] == 'T' and stack > 0:\n pop += 1\n stack -= 1\n print(len(X)-pop*2)", "resolve", "X = str(input())", "X", "str(input())", "str", "input()", "input", "stack = 0", "stack", "0", "pop = 0", "pop", "0", "for i in range(len(X)):\n if X[i] == 'S':\n stack += 1\n elif X[i] == 'T' and stack > 0:\n pop += 1\n stack -= 1\n ", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == 'S':\n stack += 1\n elif X[i] == 'T' and stack > 0:\n pop += 1\n stack -= 1\n ", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "stack += 1", "stack", "1", "elif X[i] == 'T' and stack > 0:\n pop += 1\n stack -= 1\n ", "X[i] == 'T' and stack > 0", "X[i] == 'T'", "X[i]", "X", "i", "'T'", "stack > 0", "stack", "0", "pop += 1", "pop", "1", "stack -= 1", "stack", "1", "print(len(X)-pop*2)", "print", "len(X)-pop*2", "len(X)", "len", "X", "pop*2", "pop", "2", "resolve()", "resolve", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "def resolve():\n\n X = str(input())\n stack = 0\n pop = 0\n for i in range(len(X)):\n if X[i] == 'S':\n stack += 1\n elif X[i] == 'T' and stack > 0:\n pop += 1\n stack -= 1\n print(len(X)-pop*2)", "def resolve():\n\n X = str(input())\n stack = 0\n pop = 0\n for i in range(len(X)):\n if X[i] == 'S':\n stack += 1\n elif X[i] == 'T' and stack > 0:\n pop += 1\n stack -= 1\n print(len(X)-pop*2)", "resolve" ]
import sys sys.setrecursionlimit(10 ** 5 + 10) def input(): return sys.stdin.readline().strip() def resolve(): X = str(input()) stack = 0 pop = 0 for i in range(len(X)): if X[i] == 'S': stack += 1 elif X[i] == 'T' and stack > 0: pop += 1 stack -= 1 print(len(X)-pop*2) resolve()
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 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, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 43, 2 ], [ 49, 6 ], [ 44, 9 ], [ 46, 11 ], [ 15, 14 ], [ 44, 19 ], [ 44, 23 ], [ 14, 24 ], [ 52, 27 ], [ 47, 31 ], [ 56, 31 ], [ 53, 31 ], [ 55, 34 ], [ 58, 37 ], [ 59, 41 ], [ 50, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "S = input()\nans = len(S)\ncntS = 0\nfor i in range(len(S)):\n if (S[i] == 'S'):\n cntS += 1\n else:\n if (cntS > 0):\n cntS -= 1\n ans -= 2\n else: cntS = 0\nprint(ans)", "S = input()", "S", "input()", "input", "ans = len(S)", "ans", "len(S)", "len", "S", "cntS = 0", "cntS", "0", "for i in range(len(S)):\n if (S[i] == 'S'):\n cntS += 1\n else:\n if (cntS > 0):\n cntS -= 1\n ans -= 2\n else: cntS = 0", "i", "range(len(S))", "range", "len(S)", "len", "S", "if (S[i] == 'S'):\n cntS += 1\n else:\n if (cntS > 0):\n cntS -= 1\n ans -= 2\n else: cntS = 0", "S[i] == 'S'", "S[i]", "S", "i", "'S'", "cntS += 1", "cntS", "1", "if (cntS > 0):\n cntS -= 1\n ans -= 2\n else: cntS = 0", "cntS > 0", "cntS", "0", "cntS -= 1", "cntS", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "S = input()", "input()", "S", "cntS = 0", "0", "cntS", "ans = len(S)", "len(S)", "ans", "cntS += 1", "1", "cntS", "cntS -= 1", "1", "cntS", "ans -= 2", "2", "ans" ]
S = input() ans = len(S) cntS = 0 for i in range(len(S)): if (S[i] == 'S'): cntS += 1 else: if (cntS > 0): cntS -= 1 ans -= 2 else: cntS = 0 print(ans)
[ 7, 15, 12, 13, 0, 13, 4, 13, 13, 0, 13, 39, 28, 13, 13, 13, 4, 18, 13, 13, 39, 13, 4, 13, 4, 13, 4, 13, 13, 29, 13, 23, 13, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 13, 4, 13, 13, 18, 13, 39, 17, 14, 2, 2, 18, 13, 17, 17, 2, 18, 13, 17, 17, 0, 13, 2, 4, 13, 18, 13, 17, 13, 0, 13, 4, 13, 18, 13, 17, 14, 2, 13, 13, 0, 13, 2, 13, 13, 0, 13, 17, 0, 13, 2, 17, 4, 13, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 6, 5 ], [ 32, 8 ], [ 11, 10 ], [ 10, 18 ], [ 10, 30 ], [ 32, 32 ], [ 37, 36 ], [ 41, 40 ], [ 36, 43 ], [ 46, 45 ], [ 49, 48 ], [ 121, 50 ], [ 36, 51 ], [ 48, 57 ], [ 48, 59 ], [ 76, 75 ], [ 45, 82 ], [ 100, 82 ], [ 95, 82 ], [ 85, 84 ], [ 75, 92 ], [ 84, 93 ], [ 96, 95 ], [ 75, 97 ], [ 84, 98 ], [ 101, 100 ], [ 104, 103 ], [ 75, 108 ], [ 84, 109 ], [ 103, 112 ], [ 40, 112 ], [ 124, 118 ] ]
[ "# -*- coding: utf-8 -*-\n\n\nfrom itertools import groupby\n\n\ndef runLengthEncode(S: str):\n grouped = groupby(S)\n res = []\n for k, v in grouped:\n res.append((k, str(len(list(v)))))\n return res\n\n\ndef main():\n s = input()\n length = len(s)\n s_count = 0\n\n # See:\n # https://qiita.com/Kept1994/items/e9179d1dd7c6455d6883\n runLength = runLengthEncode(s)\n\n for first, second in zip(runLength, runLength[1:]):\n if first[0] == 'S' and second[0] == 'T':\n first_count = int(first[1]) + s_count\n second_count = int(second[1])\n\n if first_count > second_count:\n s_count = first_count - second_count\n else:\n s_count = 0\n\n length -= 2 * min(first_count, second_count)\n\n print(length)\n\n\nif __name__ == '__main__':\n main()", "from itertools import groupby", "def runLengthEncode(S: str):\n grouped = groupby(S)\n res = []\n for k, v in grouped:\n res.append((k, str(len(list(v)))))\n return res", "runLengthEncode", "grouped = groupby(S)", "grouped", "groupby(S)", "groupby", "S", "res = []", "res", "[]", "for k, v in grouped:\n res.append((k, str(len(list(v)))))\n ", "k", "v", "grouped", "res.append((k, str(len(list(v)))))", "res.append", "res", "append", "(k, str(len(list(v))))", "k", "str(len(list(v)))", "str", "len(list(v))", "len", "list(v)", "list", "v", "return res", "res", "S: str", "S", "def main():\n s = input()\n length = len(s)\n s_count = 0\n\n # See:\n # https://qiita.com/Kept1994/items/e9179d1dd7c6455d6883\n runLength = runLengthEncode(s)\n\n for first, second in zip(runLength, runLength[1:]):\n if first[0] == 'S' and second[0] == 'T':\n first_count = int(first[1]) + s_count\n second_count = int(second[1])\n\n if first_count > second_count:\n s_count = first_count - second_count\n else:\n s_count = 0\n\n length -= 2 * min(first_count, second_count)\n\n print(length)", "main", "s = input()", "s", "input()", "input", "length = len(s)", "length", "len(s)", "len", "s", "s_count = 0", "s_count", "0", "runLength = runLengthEncode(s)", "runLength", "runLengthEncode(s)", "runLengthEncode", "s", "for first, second in zip(runLength, runLength[1:]):\n if first[0] == 'S' and second[0] == 'T':\n first_count = int(first[1]) + s_count\n second_count = int(second[1])\n\n if first_count > second_count:\n s_count = first_count - second_count\n else:\n s_count = 0\n\n length -= 2 * min(first_count, second_count)\n\n ", "first", "second", "zip(runLength, runLength[1:])", "zip", "runLength", "runLength[1:]", "runLength", "1:", "1", "if first[0] == 'S' and second[0] == 'T':\n first_count = int(first[1]) + s_count\n second_count = int(second[1])\n\n if first_count > second_count:\n s_count = first_count - second_count\n else:\n s_count = 0\n\n length -= 2 * min(first_count, second_count)\n\n ", "first[0] == 'S' and second[0] == 'T'", "first[0] == 'S'", "first[0]", "first", "0", "'S'", "second[0] == 'T'", "second[0]", "second", "0", "'T'", "first_count = int(first[1]) + s_count", "first_count", "int(first[1]) + s_count", "int(first[1])", "int", "first[1]", "first", "1", "s_count", "second_count = int(second[1])", "second_count", "int(second[1])", "int", "second[1]", "second", "1", "if first_count > second_count:\n s_count = first_count - second_count\n else:\n s_count = 0\n\n ", "first_count > second_count", "first_count", "second_count", "s_count = first_count - second_count", "s_count", "first_count - second_count", "first_count", "second_count", "s_count = 0", "s_count", "0", "length -= 2 * min(first_count, second_count)", "length", "2 * min(first_count, second_count)", "2", "min(first_count, second_count)", "min", "first_count", "second_count", "print(length)", "print", "length", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def runLengthEncode(S: str):\n grouped = groupby(S)\n res = []\n for k, v in grouped:\n res.append((k, str(len(list(v)))))\n return res", "def runLengthEncode(S: str):\n grouped = groupby(S)\n res = []\n for k, v in grouped:\n res.append((k, str(len(list(v)))))\n return res", "runLengthEncode", "def main():\n s = input()\n length = len(s)\n s_count = 0\n\n # See:\n # https://qiita.com/Kept1994/items/e9179d1dd7c6455d6883\n runLength = runLengthEncode(s)\n\n for first, second in zip(runLength, runLength[1:]):\n if first[0] == 'S' and second[0] == 'T':\n first_count = int(first[1]) + s_count\n second_count = int(second[1])\n\n if first_count > second_count:\n s_count = first_count - second_count\n else:\n s_count = 0\n\n length -= 2 * min(first_count, second_count)\n\n print(length)", "def main():\n s = input()\n length = len(s)\n s_count = 0\n\n # See:\n # https://qiita.com/Kept1994/items/e9179d1dd7c6455d6883\n runLength = runLengthEncode(s)\n\n for first, second in zip(runLength, runLength[1:]):\n if first[0] == 'S' and second[0] == 'T':\n first_count = int(first[1]) + s_count\n second_count = int(second[1])\n\n if first_count > second_count:\n s_count = first_count - second_count\n else:\n s_count = 0\n\n length -= 2 * min(first_count, second_count)\n\n print(length)", "main" ]
# -*- coding: utf-8 -*- from itertools import groupby def runLengthEncode(S: str): grouped = groupby(S) res = [] for k, v in grouped: res.append((k, str(len(list(v))))) return res def main(): s = input() length = len(s) s_count = 0 # See: # https://qiita.com/Kept1994/items/e9179d1dd7c6455d6883 runLength = runLengthEncode(s) for first, second in zip(runLength, runLength[1:]): if first[0] == 'S' and second[0] == 'T': first_count = int(first[1]) + s_count second_count = int(second[1]) if first_count > second_count: s_count = first_count - second_count else: s_count = 0 length -= 2 * min(first_count, second_count) print(length) if __name__ == '__main__': main()
[ 7, 15, 13, 12, 13, 15, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 13, 14, 2, 2, 13, 17, 2, 2, 13, 17, 2, 40, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 13, 14, 2, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 10, 9 ], [ 69, 11 ], [ 14, 13 ], [ 18, 17 ], [ 9, 17 ], [ 17, 22 ], [ 17, 26 ], [ 13, 30 ], [ 13, 33 ], [ 13, 38 ], [ 17, 40 ], [ 13, 43 ], [ 13, 46 ], [ 13, 51 ], [ 13, 57 ], [ 66, 63 ] ]
[ "import sys\ndef input(): return sys.stdin.readline().rstrip()\nfrom collections import deque\ndef main():\n X=input()\n stack=deque()\n for x in X:\n if x=='S' or (x=='T' and (not stack or stack[-1]=='T')):\n stack.append(x)\n elif stack and stack[-1]=='S':\n stack.pop()\n print(len(stack))\nif __name__=='__main__':\n main()", "import sys", "sys", "def input(): return sys.stdin.readline().rstrip()", "input", "from collections import deque", "def main():\n X=input()\n stack=deque()\n for x in X:\n if x=='S' or (x=='T' and (not stack or stack[-1]=='T')):\n stack.append(x)\n elif stack and stack[-1]=='S':\n stack.pop()\n print(len(stack))", "main", "X=input()", "X", "input()", "input", "stack=deque()", "stack", "deque()", "deque", "for x in X:\n if x=='S' or (x=='T' and (not stack or stack[-1]=='T')):\n stack.append(x)\n elif stack and stack[-1]=='S':\n stack.pop()\n ", "x", "X", "if x=='S' or (x=='T' and (not stack or stack[-1]=='T')):\n stack.append(x)\n elif stack and stack[-1]=='S':\n stack.pop()\n ", "x=='S' or (x=='T' and (not stack or stack[-1]=='T'))", "x=='S'", "x", "'S'", "x=='T' and (not stack or stack[-1]=='T')", "x=='T'", "x", "'T'", "not stack or stack[-1]=='T'", "not stack", "stack", "stack[-1]=='T'", "stack[-1]", "stack", "-1", "'T'", "stack.append(x)", "stack.append", "stack", "append", "x", "elif stack and stack[-1]=='S':\n stack.pop()\n ", "stack and stack[-1]=='S'", "stack", "stack[-1]=='S'", "stack[-1]", "stack", "-1", "'S'", "stack.pop()", "stack.pop", "stack", "pop", "print(len(stack))", "print", "len(stack)", "len", "stack", "if __name__=='__main__':\n main()", "__name__=='__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n X=input()\n stack=deque()\n for x in X:\n if x=='S' or (x=='T' and (not stack or stack[-1]=='T')):\n stack.append(x)\n elif stack and stack[-1]=='S':\n stack.pop()\n print(len(stack))", "def main():\n X=input()\n stack=deque()\n for x in X:\n if x=='S' or (x=='T' and (not stack or stack[-1]=='T')):\n stack.append(x)\n elif stack and stack[-1]=='S':\n stack.pop()\n print(len(stack))", "main", "def input(): return sys.stdin.readline().rstrip()", "def input(): return sys.stdin.readline().rstrip()", "input" ]
import sys def input(): return sys.stdin.readline().rstrip() from collections import deque def main(): X=input() stack=deque() for x in X: if x=='S' or (x=='T' and (not stack or stack[-1]=='T')): stack.append(x) elif stack and stack[-1]=='S': stack.pop() print(len(stack)) if __name__=='__main__': main()
[ 7, 15, 15, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 41, 28, 13, 4, 13, 17, 13, 4, 18, 13, 13, 0, 13, 13, 0, 13, 4, 13, 13, 0, 13, 39, 0, 13, 17, 28, 13, 13, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 13, 13, 39, 13, 13, 13, 0, 13, 17, 14, 2, 18, 18, 13, 17, 17, 17, 0, 13, 18, 13, 39, 17, 14, 2, 18, 18, 13, 17, 17, 17, 0, 13, 18, 13, 39, 2, 4, 13, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 42, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 2, 18, 13, 17, 13, 0, 13, 18, 13, 17, 14, 40, 13, 13, 0, 13, 2, 13, 13, 0, 13, 13, 0, 13, 17, 0, 13, 13, 4, 13, 2, 13, 2, 17, 13, 10, 18, 13, 10, 4, 13, 10, 18, 13, 10, 17, 13, 10, 4, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 18, 13, 10, 17, 13, 10, 13, 13, 10, 13, 13, 10, 17, 13 ]
[ [ 178, 5 ], [ 196, 9 ], [ 179, 12 ], [ 16, 15 ], [ 197, 19 ], [ 179, 22 ], [ 15, 23 ], [ 199, 25 ], [ 169, 28 ], [ 200, 31 ], [ 179, 31 ], [ 172, 33 ], [ 166, 36 ], [ 187, 43 ], [ 173, 51 ], [ 181, 58 ], [ 173, 64 ], [ 157, 69 ], [ 173, 71 ], [ 158, 78 ], [ 173, 78 ], [ 202, 83 ], [ 158, 85 ], [ 173, 85 ], [ 158, 90 ], [ 173, 90 ], [ 203, 96 ], [ 158, 96 ], [ 173, 96 ], [ 205, 98 ], [ 193, 101 ], [ 160, 106 ], [ 203, 111 ], [ 158, 111 ], [ 173, 111 ], [ 175, 113 ], [ 203, 118 ], [ 158, 118 ], [ 173, 118 ], [ 190, 120 ], [ 161, 123 ], [ 206, 125 ], [ 215, 125 ], [ 185, 125 ], [ 163, 127 ], [ 176, 129 ], [ 191, 133 ], [ 164, 134 ], [ 184, 136 ], [ 191, 138 ], [ 164, 139 ], [ 211, 141 ], [ 164, 142 ], [ 214, 144 ], [ 208, 147 ], [ 191, 148 ], [ 197, 152 ], [ 209, 155 ], [ 212, 155 ], [ 194, 155 ], [ 157, 158 ], [ 160, 161 ], [ 163, 164 ], [ 166, 167 ], [ 169, 170 ], [ 172, 173 ], [ 175, 176 ], [ 178, 179 ], [ 181, 182 ], [ 184, 185 ], [ 187, 188 ], [ 190, 191 ], [ 193, 194 ], [ 196, 197 ], [ 199, 200 ], [ 202, 203 ], [ 205, 206 ], [ 191, 208 ], [ 208, 209 ], [ 164, 211 ], [ 211, 212 ], [ 214, 215 ] ]
[ "from itertools import groupby\nimport heapq\n\nX=input()\nN=len(X)\nX=[X[i] for i in range(0,N)]\nX=groupby(X)\ndata=[]\ni=0\nfor key,group in X:\n g=len(list(group))\n data.append((i,key,g))\n i+=1\n\nif data[0][1]=='T':\n data=data[1:]\nif data[-1][1]=='S':\n data=data[:len(data)-1]\n\n\nheapq.heapify(data)\nleft=0\nans=0\nwhile data:\n S=heapq.heappop(data)\n T=heapq.heappop(data)\n s=S[2]+left\n t=T[2]\n if s>=t:\n left=s-t\n ans+=t\n else:\n left=0\n ans+=s\n\nprint(N-2*ans)", "from itertools import groupby", "import heapq", "heapq", "X=input()", "X", "input()", "input", "N=len(X)", "N", "len(X)", "len", "X", "X[i] for i in range(0,N)", "for i in range(0,N)", "i", "range(0,N)", "range", "0", "N", "for i in range(0,N)", "X[i]", "X", "i", "X=[X[i] for i in range(0,N)]", "X", "[X[i] for i in range(0,N)]", "X=groupby(X)", "X", "groupby(X)", "groupby", "X", "data=[]", "data", "[]", "i=0", "i", "0", "for key,group in X:\n g=len(list(group))\n data.append((i,key,g))\n i+=1", "key", "group", "X", "g=len(list(group))", "g", "len(list(group))", "len", "list(group)", "list", "group", "data.append((i,key,g))", "data.append", "data", "append", "(i,key,g)", "i", "key", "g", "i+=1", "i", "1", "if data[0][1]=='T':\n data=data[1:]", "data[0][1]=='T'", "data[0][1]", "[0]", "data", "0", "1", "'T'", "data=data[1:]", "data", "data[1:]", "data", "1:", "1", "if data[-1][1]=='S':\n data=data[:len(data)-1]", "data[-1][1]=='S'", "data[-1][1]", "[-1]", "data", "-1", "1", "'S'", "data=data[:len(data)-1]", "data", "data[:len(data)-1]", "data", ":len(data)-1", "len(data)-1", "len(data)", "len", "data", "1", "heapq.heapify(data)", "heapq.heapify", "heapq", "heapify", "data", "left=0", "left", "0", "ans=0", "ans", "0", "while data:\n S=heapq.heappop(data)\n T=heapq.heappop(data)\n s=S[2]+left\n t=T[2]\n if s>=t:\n left=s-t\n ans+=t\n else:\n left=0\n ans+=s", "data", "S=heapq.heappop(data)", "S", "heapq.heappop(data)", "heapq.heappop", "heapq", "heappop", "data", "T=heapq.heappop(data)", "T", "heapq.heappop(data)", "heapq.heappop", "heapq", "heappop", "data", "s=S[2]+left", "s", "S[2]+left", "S[2]", "S", "2", "left", "t=T[2]", "t", "T[2]", "T", "2", "if s>=t:\n left=s-t\n ans+=t\n else:\n left=0\n ans+=s", "s>=t", "s", "t", "left=s-t", "left", "s-t", "s", "t", "ans+=t", "ans", "t", "left=0", "left", "0", "ans+=s", "ans", "s", "print(N-2*ans)", "print", "N-2*ans", "N", "2*ans", "2", "ans", "data=data[1:]", "data[1:]", "data", "S=heapq.heappop(data)", "heapq.heappop(data)", "S", "t=T[2]", "T[2]", "t", "i=0", "0", "i", "X=groupby(X)", "groupby(X)", "X", "data=[]", "[]", "data", "T=heapq.heappop(data)", "heapq.heappop(data)", "T", "X=input()", "input()", "X", "i+=1", "1", "i", "left=s-t", "s-t", "left", "g=len(list(group))", "len(list(group))", "g", "s=S[2]+left", "S[2]+left", "s", "ans=0", "0", "ans", "N=len(X)", "len(X)", "N", "X=[X[i] for i in range(0,N)]", "[X[i] for i in range(0,N)]", "X", "data=data[:len(data)-1]", "data[:len(data)-1]", "data", "left=0", "0", "left", "ans+=s", "s", "ans", "ans+=t", "t", "ans", "left=0", "0", "left" ]
from itertools import groupby import heapq X=input() N=len(X) X=[X[i] for i in range(0,N)] X=groupby(X) data=[] i=0 for key,group in X: g=len(list(group)) data.append((i,key,g)) i+=1 if data[0][1]=='T': data=data[1:] if data[-1][1]=='S': data=data[:len(data)-1] heapq.heapify(data) left=0 ans=0 while data: S=heapq.heappop(data) T=heapq.heappop(data) s=S[2]+left t=T[2] if s>=t: left=s-t ans+=t else: left=0 ans+=s print(N-2*ans)
[ 7, 15, 13, 15, 12, 13, 0, 13, 4, 13, 18, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 14, 40, 13, 4, 18, 13, 13, 18, 13, 13, 9, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 18, 13, 13, 9, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 9, 4, 18, 13, 13, 18, 13, 13, 4, 13, 4, 13, 13, 23, 13, 12, 13, 12, 13, 28, 13, 18, 13, 13, 28, 13, 4, 18, 13, 13, 27, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 8, 7 ], [ 70, 11 ], [ 15, 14 ], [ 70, 20 ], [ 7, 23 ], [ 7, 26 ], [ 70, 29 ], [ 14, 30 ], [ 7, 35 ], [ 7, 40 ], [ 70, 43 ], [ 14, 44 ], [ 70, 49 ], [ 14, 50 ], [ 7, 54 ], [ 7, 59 ], [ 70, 62 ], [ 14, 63 ], [ 7, 68 ], [ 70, 70 ], [ 77, 76 ], [ 82, 81 ], [ 76, 84 ], [ 81, 87 ], [ 90, 89 ], [ 74, 91 ], [ 94, 93 ], [ 89, 96 ], [ 108, 98 ], [ 93, 99 ], [ 111, 105 ] ]
[ "#!/usr/bin/env python3\nimport sys\nfrom collections import deque\n\n\ndef solve(X: str):\n stack = deque(X[0])\n for i in range(1, len(X)):\n if not stack:\n stack.append(X[i])\n continue\n if stack[-1] == \"T\":\n stack.append(X[i])\n continue\n if X[i] == \"T\":\n stack.pop()\n continue\n stack.append(X[i])\n\n print(len(stack))\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n X = next(tokens) # type: str\n solve(X)\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "from collections import deque", "def solve(X: str):\n stack = deque(X[0])\n for i in range(1, len(X)):\n if not stack:\n stack.append(X[i])\n continue\n if stack[-1] == \"T\":\n stack.append(X[i])\n continue\n if X[i] == \"T\":\n stack.pop()\n continue\n stack.append(X[i])\n\n print(len(stack))\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)", "solve", "stack = deque(X[0])", "stack", "deque(X[0])", "deque", "X[0]", "X", "0", "for i in range(1, len(X)):\n if not stack:\n stack.append(X[i])\n continue\n if stack[-1] == \"T\":\n stack.append(X[i])\n continue\n if X[i] == \"T\":\n stack.pop()\n continue\n stack.append(X[i])\n\n ", "i", "range(1, len(X))", "range", "1", "len(X)", "len", "X", "if not stack:\n stack.append(X[i])\n continue\n ", "not stack", "stack", "stack.append(X[i])", "stack.append", "stack", "append", "X[i]", "X", "i", "continue", "if stack[-1] == \"T\":\n stack.append(X[i])\n continue\n ", "stack[-1] == \"T\"", "stack[-1]", "stack", "-1", "\"T\"", "stack.append(X[i])", "stack.append", "stack", "append", "X[i]", "X", "i", "continue", "if X[i] == \"T\":\n stack.pop()\n continue\n ", "X[i] == \"T\"", "X[i]", "X", "i", "\"T\"", "stack.pop()", "stack.pop", "stack", "pop", "continue", "stack.append(X[i])", "stack.append", "stack", "append", "X[i]", "X", "i", "print(len(stack))", "print", "len(stack)", "len", "stack", "X: str", "X", "def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n X = next(tokens) # type: str\n solve(X)", "main", "def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n ", "iterate_tokens", "for line in sys.stdin:\n for word in line.split():\n yield word\n ", "line", "sys.stdin", "sys", "stdin", "for word in line.split():\n yield word\n ", "word", "line.split()", "line.split", "line", "split", "yield word", "word", "tokens = iterate_tokens()", "tokens", "iterate_tokens()", "iterate_tokens", "X = next(tokens)", "X", "next(tokens)", "next", "tokens", "solve(X)", "solve", "X", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def solve(X: str):\n stack = deque(X[0])\n for i in range(1, len(X)):\n if not stack:\n stack.append(X[i])\n continue\n if stack[-1] == \"T\":\n stack.append(X[i])\n continue\n if X[i] == \"T\":\n stack.pop()\n continue\n stack.append(X[i])\n\n print(len(stack))\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)", "def solve(X: str):\n stack = deque(X[0])\n for i in range(1, len(X)):\n if not stack:\n stack.append(X[i])\n continue\n if stack[-1] == \"T\":\n stack.append(X[i])\n continue\n if X[i] == \"T\":\n stack.pop()\n continue\n stack.append(X[i])\n\n print(len(stack))\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)", "solve", "def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n X = next(tokens) # type: str\n solve(X)", "def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n X = next(tokens) # type: str\n solve(X)", "main" ]
#!/usr/bin/env python3 import sys from collections import deque def solve(X: str): stack = deque(X[0]) for i in range(1, len(X)): if not stack: stack.append(X[i]) continue if stack[-1] == "T": stack.append(X[i]) continue if X[i] == "T": stack.pop() continue stack.append(X[i]) print(len(stack)) # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() X = next(tokens) # type: str solve(X) if __name__ == '__main__': main()
[ 7, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 14, 2, 13, 17, 14, 2, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 28, 2 ], [ 28, 5 ], [ 9, 8 ], [ 8, 13 ], [ 26, 17 ], [ 26, 22 ], [ 29, 23 ], [ 28, 26 ], [ 28, 29 ] ]
[ "s=t=0\nfor i in input():\n if i==\"S\":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\":s+=1\n elif s>0:s-=1\n else:t+=1", "i", "input()", "input", "if i==\"S\":s+=1\n elif s>0:s-=1\n else:t+=1", "i==\"S\"", "i", "\"S\"", "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=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, 0, 13, 39, 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, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 50, 2 ], [ 47, 6 ], [ 10, 9 ], [ 51, 9 ], [ 9, 13 ], [ 48, 17 ], [ 9, 19 ], [ 48, 25 ], [ 48, 29 ], [ 48, 34 ], [ 9, 36 ], [ 48, 39 ], [ 48, 45 ], [ 47, 48 ], [ 50, 51 ] ]
[ "x = input()\nans = []\n\nfor i in x:\n if i == 'S':\n ans.append(i)\n else:\n if len(ans) == 0 or ans[-1] == 'T':\n ans.append(i)\n else:\n ans.pop()\nprint(len(ans))", "x = input()", "x", "input()", "input", "ans = []", "ans", "[]", "for i in x:\n if i == 'S':\n ans.append(i)\n else:\n if len(ans) == 0 or ans[-1] == 'T':\n ans.append(i)\n else:\n ans.pop()", "i", "x", "if i == 'S':\n ans.append(i)\n else:\n if len(ans) == 0 or ans[-1] == 'T':\n ans.append(i)\n else:\n ans.pop()", "i == 'S'", "i", "'S'", "ans.append(i)", "ans.append", "ans", "append", "i", "if len(ans) == 0 or ans[-1] == 'T':\n ans.append(i)\n else:\n ans.pop()", "len(ans) == 0 or ans[-1] == 'T'", "len(ans) == 0", "len(ans)", "len", "ans", "0", "ans[-1] == 'T'", "ans[-1]", "ans", "-1", "'T'", "ans.append(i)", "ans.append", "ans", "append", "i", "ans.pop()", "ans.pop", "ans", "pop", "print(len(ans))", "print", "len(ans)", "len", "ans", "ans = []", "[]", "ans", "x = input()", "input()", "x" ]
x = input() ans = [] for i in x: if i == 'S': ans.append(i) else: if len(ans) == 0 or ans[-1] == 'T': ans.append(i) else: ans.pop() print(len(ans))
[ 7, 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, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 48, 2 ], [ 39, 6 ], [ 42, 8 ], [ 12, 11 ], [ 49, 11 ], [ 11, 15 ], [ 36, 18 ], [ 40, 22 ], [ 46, 22 ], [ 37, 22 ], [ 45, 25 ], [ 51, 28 ], [ 46, 33 ], [ 37, 33 ], [ 40, 33 ], [ 52, 34 ], [ 43, 34 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "x=input()\ns,t=0,0\n\nfor m in x:\n if m==\"S\":\n s+=1\n else:\n if s>0:\n s-=1\n else:\n t+=1\nprint(s+t)", "x=input()", "x", "input()", "input", "s,t=0,0", "s", "0", "t", "0", "for m in x:\n if m==\"S\":\n s+=1\n else:\n if s>0:\n s-=1\n else:\n t+=1", "m", "x", "if m==\"S\":\n s+=1\n else:\n if s>0:\n s-=1\n else:\n t+=1", "m==\"S\"", "m", "\"S\"", "s+=1", "s", "1", "if s>0:\n s-=1\n else:\n t+=1", "s>0", "s", "0", "s-=1", "s", "1", "t+=1", "t", "1", "print(s+t)", "print", "s+t", "s", "t", "s+=1", "1", "s", "s,t=0,0", "0", "s", "t=0,0", "0", "t", "s-=1", "1", "s", "x=input()", "input()", "x", "t+=1", "1", "t" ]
x=input() s,t=0,0 for m in x: if m=="S": s+=1 else: if s>0: s-=1 else: t+=1 print(s+t)
[ 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 37, 2 ], [ 52, 6 ], [ 49, 9 ], [ 13, 12 ], [ 38, 12 ], [ 12, 16 ], [ 40, 19 ], [ 53, 23 ], [ 44, 23 ], [ 41, 23 ], [ 43, 26 ], [ 46, 29 ], [ 44, 34 ], [ 41, 34 ], [ 53, 34 ], [ 47, 35 ], [ 50, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "s = input()\n\nS = 0\nT = 0\n\nfor c in s:\n if c == 'S':\n S += 1\n else:\n if S > 0:\n S -= 1\n else:\n T += 1\n \nprint(S+T)", "s = input()", "s", "input()", "input", "S = 0", "S", "0", "T = 0", "T", "0", "for c in s:\n if c == 'S':\n S += 1\n else:\n if S > 0:\n S -= 1\n else:\n T += 1\n ", "c", "s", "if c == 'S':\n S += 1\n else:\n if S > 0:\n S -= 1\n else:\n T += 1\n ", "c == 'S'", "c", "'S'", "S += 1", "S", "1", "if S > 0:\n S -= 1\n else:\n T += 1\n ", "S > 0", "S", "0", "S -= 1", "S", "1", "T += 1", "T", "1", "print(S+T)", "print", "S+T", "S", "T", "s = input()", "input()", "s", "S += 1", "1", "S", "S -= 1", "1", "S", "T += 1", "1", "T", "T = 0", "0", "T", "S = 0", "0", "S" ]
s = input() S = 0 T = 0 for c in s: if c == 'S': S += 1 else: if S > 0: S -= 1 else: T += 1 print(S+T)
[ 7, 0, 13, 12, 4, 13, 13, 0, 13, 17, 23, 0, 13, 12, 4, 13, 4, 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, 13, 13, 0, 13, 17, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 14, 13, 4, 13, 13, 23, 13, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 4, 18, 13, 13, 13, 42, 2, 2, 2, 4, 13, 13, 17, 2, 18, 13, 17, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13, 10, 2, 13, 10, 39, 13, 10, 12, 13, 10, 17, 13 ]
[ [ 148, 2 ], [ 9, 8 ], [ 136, 12 ], [ 127, 19 ], [ 139, 32 ], [ 124, 43 ], [ 151, 51 ], [ 142, 54 ], [ 133, 59 ], [ 73, 71 ], [ 73, 73 ], [ 130, 75 ], [ 125, 77 ], [ 145, 79 ], [ 83, 82 ], [ 131, 82 ], [ 146, 86 ], [ 82, 88 ], [ 146, 95 ], [ 146, 99 ], [ 146, 104 ], [ 146, 109 ], [ 146, 113 ], [ 146, 119 ], [ 124, 125 ], [ 127, 128 ], [ 130, 131 ], [ 133, 134 ], [ 136, 137 ], [ 139, 140 ], [ 142, 143 ], [ 145, 146 ], [ 148, 149 ], [ 151, 152 ] ]
[ "printn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split()) \nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 10**9 + 7\n\ndef ddprint(x):\n if DBG:\n print(x)\n\nx = ins()\ns = []\nfor c in x:\n s.append(c)\n while len(s)>1 and s[-2]=='S' and s[-1]=='T':\n s.pop()\n s.pop()\nprint(len(s))", "printn = lambda x: print(x,end='')", "printn", "lambda x: print(x,end='')", "print(x,end='')", "print", "x", "end=''", "end", "''", "x", "inn = lambda : int(input())", "inn", "lambda : int(input())", "int(input())", "int", "input()", "input", "inl = lambda: list(map(int, input().split()))", "inl", "lambda: list(map(int, input().split()))", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "inm = lambda: map(int, input().split())", "inm", "lambda: map(int, input().split())", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ins = lambda : input().strip()", "ins", "lambda : input().strip()", "input().strip()", "().strip", "()", "input", "strip", "DBG = True", "DBG", "True", "BIG = 10**18", "BIG", "10**18", "10", "18", "R = 10**9 + 7", "R", "10**9 + 7", "10**9", "10", "9", "7", "def ddprint(x):\n if DBG:\n print(x)", "ddprint", "if DBG:\n print(x)", "DBG", "print(x)", "print", "x", "x", "x", "x = ins()", "x", "ins()", "ins", "s = []", "s", "[]", "for c in x:\n s.append(c)\n while len(s)>1 and s[-2]=='S' and s[-1]=='T':\n s.pop()\n s.pop()", "c", "x", "s.append(c)", "s.append", "s", "append", "c", "while len(s)>1 and s[-2]=='S' and s[-1]=='T':\n s.pop()\n s.pop()", "len(s)>1 and s[-2]=='S' and s[-1]=='T'", "len(s)>1 and s[-2]=='S'", "len(s)>1", "len(s)", "len", "s", "1", "s[-2]=='S'", "s[-2]", "s", "-2", "'S'", "s[-1]=='T'", "s[-1]", "s", "-1", "'T'", "s.pop()", "s.pop", "s", "pop", "s.pop()", "s.pop", "s", "pop", "print(len(s))", "print", "len(s)", "len", "s", "def ddprint(x):\n if DBG:\n print(x)", "def ddprint(x):\n if DBG:\n print(x)", "ddprint", "ins = lambda : input().strip()", "lambda : input().strip()", "ins", "inl = lambda: list(map(int, input().split()))", "lambda: list(map(int, input().split()))", "inl", "x = ins()", "ins()", "x", "R = 10**9 + 7", "10**9 + 7", "R", "inn = lambda : int(input())", "lambda : int(input())", "inn", "inm = lambda: map(int, input().split())", "lambda: map(int, input().split())", "inm", "BIG = 10**18", "10**18", "BIG", "s = []", "[]", "s", "printn = lambda x: print(x,end='')", "lambda x: print(x,end='')", "printn", "DBG = True", "True", "DBG" ]
printn = lambda x: print(x,end='') inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda : input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 def ddprint(x): if DBG: print(x) x = ins() s = [] for c in x: s.append(c) while len(s)>1 and s[-2]=='S' and s[-1]=='T': s.pop() s.pop() print(len(s))
[ 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 37, 2 ], [ 46, 6 ], [ 40, 9 ], [ 38, 12 ], [ 15, 14 ], [ 38, 14 ], [ 14, 18 ], [ 49, 21 ], [ 47, 25 ], [ 53, 25 ], [ 50, 25 ], [ 43, 28 ], [ 52, 31 ], [ 44, 35 ], [ 41, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "x = input()\ns = 0\nans = len(x)\nfor c in x:\n if c=='S':\n s += 1\n elif s>0:\n ans -= 2\n s -= 1\nprint(ans)", "x = input()", "x", "input()", "input", "s = 0", "s", "0", "ans = len(x)", "ans", "len(x)", "len", "x", "for c in x:\n if c=='S':\n s += 1\n elif s>0:\n ans -= 2\n s -= 1", "c", "x", "if c=='S':\n s += 1\n elif s>0:\n ans -= 2\n s -= 1", "c=='S'", "c", "'S'", "s += 1", "s", "1", "elif s>0:\n ans -= 2\n s -= 1", "s>0", "s", "0", "ans -= 2", "ans", "2", "s -= 1", "s", "1", "print(ans)", "print", "ans", "x = input()", "input()", "x", "ans = len(x)", "len(x)", "ans", "ans -= 2", "2", "ans", "s = 0", "0", "s", "s += 1", "1", "s", "s -= 1", "1", "s" ]
x = input() s = 0 ans = len(x) for c in x: if c=='S': s += 1 elif s>0: ans -= 2 s -= 1 print(ans)
[ 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, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 43, 2 ], [ 52, 6 ], [ 46, 9 ], [ 13, 12 ], [ 44, 17 ], [ 44, 21 ], [ 12, 22 ], [ 55, 25 ], [ 47, 29 ], [ 50, 29 ], [ 56, 29 ], [ 49, 32 ], [ 58, 35 ], [ 59, 40 ], [ 53, 40 ], [ 50, 41 ], [ 56, 41 ], [ 47, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "x = input()\n\nans = 0\nstock = 0\n\nfor i in range(len(x)):\n if x[i] == 'S':\n stock += 1\n elif stock > 0:\n stock -= 1\n else:\n ans += 1\n\nprint(ans+stock)", "x = input()", "x", "input()", "input", "ans = 0", "ans", "0", "stock = 0", "stock", "0", "for i in range(len(x)):\n if x[i] == 'S':\n stock += 1\n elif stock > 0:\n stock -= 1\n else:\n ans += 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == 'S':\n stock += 1\n elif stock > 0:\n stock -= 1\n else:\n ans += 1", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "stock += 1", "stock", "1", "elif stock > 0:\n stock -= 1\n ", "stock > 0", "stock", "0", "stock -= 1", "stock", "1", "ans += 1", "ans", "1", "print(ans+stock)", "print", "ans+stock", "ans", "stock", "x = input()", "input()", "x", "stock = 0", "0", "stock", "stock -= 1", "1", "stock", "ans = 0", "0", "ans", "stock += 1", "1", "stock", "ans += 1", "1", "ans" ]
x = input() ans = 0 stock = 0 for i in range(len(x)): if x[i] == 'S': stock += 1 elif stock > 0: stock -= 1 else: ans += 1 print(ans+stock)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 15, 0, 13, 4, 13, 39, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 17, 14, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 68, 2 ], [ 62, 8 ], [ 69, 11 ], [ 65, 14 ], [ 20, 19 ], [ 63, 22 ], [ 69, 26 ], [ 19, 27 ], [ 66, 31 ], [ 66, 39 ], [ 66, 44 ], [ 66, 49 ], [ 66, 53 ], [ 66, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "s=list(input())\nn=len(s)\nfrom collections import deque\nq=deque([])\n\nfor i in range(n):\n if s[i]=='S':\n q.append('S')\n else:\n if q:\n if q[-1]=='T':\n q.append('T')\n else:\n q.pop()\n else:\n q.append('T')\nprint(len(q))", "s=list(input())", "s", "list(input())", "list", "input()", "input", "n=len(s)", "n", "len(s)", "len", "s", "from collections import deque", "q=deque([])", "q", "deque([])", "deque", "[]", "for i in range(n):\n if s[i]=='S':\n q.append('S')\n else:\n if q:\n if q[-1]=='T':\n q.append('T')\n else:\n q.pop()\n else:\n q.append('T')", "i", "range(n)", "range", "n", "if s[i]=='S':\n q.append('S')\n else:\n if q:\n if q[-1]=='T':\n q.append('T')\n else:\n q.pop()\n else:\n q.append('T')", "s[i]=='S'", "s[i]", "s", "i", "'S'", "q.append('S')", "q.append", "q", "append", "'S'", "if q:\n if q[-1]=='T':\n q.append('T')\n else:\n q.pop()\n else:\n q.append('T')", "q", "if q[-1]=='T':\n q.append('T')\n else:\n q.pop()\n ", "q[-1]=='T'", "q[-1]", "q", "-1", "'T'", "q.append('T')", "q.append", "q", "append", "'T'", "q.pop()", "q.pop", "q", "pop", "q.append('T')", "q.append", "q", "append", "'T'", "print(len(q))", "print", "len(q)", "len", "q", "n=len(s)", "len(s)", "n", "q=deque([])", "deque([])", "q", "s=list(input())", "list(input())", "s" ]
s=list(input()) n=len(s) from collections import deque q=deque([]) for i in range(n): if s[i]=='S': q.append('S') else: if q: if q[-1]=='T': q.append('T') else: q.pop() else: q.append('T') print(len(q))
[ 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, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 67, 2 ], [ 73, 6 ], [ 68, 9 ], [ 58, 11 ], [ 70, 14 ], [ 18, 17 ], [ 74, 20 ], [ 68, 24 ], [ 17, 25 ], [ 55, 28 ], [ 59, 32 ], [ 65, 32 ], [ 77, 32 ], [ 56, 32 ], [ 61, 35 ], [ 76, 38 ], [ 77, 42 ], [ 56, 42 ], [ 59, 42 ], [ 65, 42 ], [ 64, 45 ], [ 74, 50 ], [ 62, 52 ], [ 71, 52 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "x=input()\nl=len(x)\nc=0\nans=0\nfor i in range(l):\n if x[i]=='S':\n c+=1\n else:\n if c>0:\n ans+=1\n c-=1\n if c<0:\n c+=1\nprint(l-ans*2)", "x=input()", "x", "input()", "input", "l=len(x)", "l", "len(x)", "len", "x", "c=0", "c", "0", "ans=0", "ans", "0", "for i in range(l):\n if x[i]=='S':\n c+=1\n else:\n if c>0:\n ans+=1\n c-=1\n if c<0:\n c+=1", "i", "range(l)", "range", "l", "if x[i]=='S':\n c+=1\n else:\n if c>0:\n ans+=1\n c-=1\n ", "x[i]=='S'", "x[i]", "x", "i", "'S'", "c+=1", "c", "1", "if c>0:\n ans+=1\n ", "c>0", "c", "0", "ans+=1", "ans", "1", "c-=1", "c", "1", "if c<0:\n c+=1", "c<0", "c", "0", "c+=1", "c", "1", "print(l-ans*2)", "print", "l-ans*2", "l", "ans*2", "ans", "2", "c+=1", "1", "c", "c=0", "0", "c", "ans+=1", "1", "ans", "c+=1", "1", "c", "x=input()", "input()", "x", "ans=0", "0", "ans", "l=len(x)", "len(x)", "l", "c-=1", "1", "c" ]
x=input() l=len(x) c=0 ans=0 for i in range(l): if x[i]=='S': c+=1 else: if c>0: ans+=1 c-=1 if c<0: c+=1 print(l-ans*2)
[ 7, 0, 13, 4, 13, 15, 0, 13, 4, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 13, 4, 18, 13, 13, 0, 13, 17, 42, 13, 0, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 57, 2 ], [ 51, 7 ], [ 48, 11 ], [ 15, 14 ], [ 58, 14 ], [ 14, 18 ], [ 52, 22 ], [ 14, 24 ], [ 52, 29 ], [ 54, 32 ], [ 60, 37 ], [ 52, 40 ], [ 61, 46 ], [ 55, 46 ], [ 49, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "x = input()\nfrom collections import deque\n\nq = deque()\nans = \"\"\nfor i in x:\n if i == \"S\":\n q.append(i)\n else:\n if q:\n q.popleft()\n else:\n ans += \"T\"\nwhile q:\n ans += q.popleft()\nprint(len(ans))", "x = input()", "x", "input()", "input", "from collections import deque", "q = deque()", "q", "deque()", "deque", "ans = \"\"", "ans", "\"\"", "for i in x:\n if i == \"S\":\n q.append(i)\n else:\n if q:\n q.popleft()\n else:\n ans += \"T\"", "i", "x", "if i == \"S\":\n q.append(i)\n else:\n if q:\n q.popleft()\n else:\n ans += \"T\"", "i == \"S\"", "i", "\"S\"", "q.append(i)", "q.append", "q", "append", "i", "if q:\n q.popleft()\n else:\n ans += \"T\"", "q", "q.popleft()", "q.popleft", "q", "popleft", "ans += \"T\"", "ans", "\"T\"", "while q:\n ans += q.popleft()", "q", "ans += q.popleft()", "ans", "q.popleft()", "q.popleft", "q", "popleft", "print(len(ans))", "print", "len(ans)", "len", "ans", "ans = \"\"", "\"\"", "ans", "q = deque()", "deque()", "q", "ans += \"T\"", "\"T\"", "ans", "x = input()", "input()", "x", "ans += q.popleft()", "q.popleft()", "ans" ]
x = input() from collections import deque q = deque() ans = "" for i in x: if i == "S": q.append(i) else: if q: q.popleft() else: ans += "T" while q: ans += q.popleft() print(len(ans))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 18, 13, 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, 17, 13 ]
[ [ 60, 2 ], [ 69, 8 ], [ 63, 11 ], [ 15, 14 ], [ 61, 19 ], [ 64, 22 ], [ 73, 22 ], [ 67, 22 ], [ 55, 22 ], [ 61, 27 ], [ 14, 28 ], [ 57, 31 ], [ 54, 34 ], [ 61, 39 ], [ 14, 40 ], [ 66, 43 ], [ 72, 46 ], [ 58, 51 ], [ 70, 51 ], [ 73, 52 ], [ 67, 52 ], [ 55, 52 ], [ 64, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "X=list(input())\nans=0\ncnt=0\nfor i in range(len(X)):\n if cnt==0:\n if X[i]==\"T\":\n ans+=1\n else:\n cnt+=1\n else:\n if X[i]==\"T\":\n cnt-=1\n else:\n cnt+=1\n \nprint(ans+cnt)", "X=list(input())", "X", "list(input())", "list", "input()", "input", "ans=0", "ans", "0", "cnt=0", "cnt", "0", "for i in range(len(X)):\n if cnt==0:\n if X[i]==\"T\":\n ans+=1\n else:\n cnt+=1\n else:\n if X[i]==\"T\":\n cnt-=1\n else:\n cnt+=1\n ", "i", "range(len(X))", "range", "len(X)", "len", "X", "if cnt==0:\n if X[i]==\"T\":\n ans+=1\n else:\n cnt+=1\n else:\n if X[i]==\"T\":\n cnt-=1\n else:\n cnt+=1\n ", "cnt==0", "cnt", "0", "if X[i]==\"T\":\n ans+=1\n else:\n cnt+=1\n ", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "ans+=1", "ans", "1", "cnt+=1", "cnt", "1", "if X[i]==\"T\":\n cnt-=1\n else:\n cnt+=1\n ", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "cnt-=1", "cnt", "1", "cnt+=1", "cnt", "1", "print(ans+cnt)", "print", "ans+cnt", "ans", "cnt", "cnt+=1", "1", "cnt", "ans+=1", "1", "ans", "X=list(input())", "list(input())", "X", "cnt=0", "0", "cnt", "cnt-=1", "1", "cnt", "ans=0", "0", "ans", "cnt+=1", "1", "cnt" ]
X=list(input()) ans=0 cnt=0 for i in range(len(X)): if cnt==0: if X[i]=="T": ans+=1 else: cnt+=1 else: if X[i]=="T": cnt-=1 else: cnt+=1 print(ans+cnt)
[ 7, 15, 0, 13, 4, 13, 4, 13, 12, 8, 2, 13, 17, 17, 17, 23, 4, 13, 0, 13, 4, 13, 28, 13, 13, 14, 13, 14, 2, 40, 13, 40, 18, 13, 17, 17, 4, 18, 13, 13, 13, 14, 2, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 67, 3 ], [ 64, 19 ], [ 24, 23 ], [ 68, 23 ], [ 65, 30 ], [ 65, 33 ], [ 65, 38 ], [ 23, 40 ], [ 65, 43 ], [ 65, 46 ], [ 65, 51 ], [ 65, 55 ], [ 23, 57 ], [ 65, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "from collections import deque\nS=list(map(lambda x: 1 if x==\"T\" else 0,input()))\n\nq=deque()\n\nfor i in S:\n\n if i:\n if (not q) or q[-1]!=0:\n q.append(i)\n elif q and q[-1]==0:\n q.pop()\n else:\n q.append(i)\nprint(len(q))", "from collections import deque", "S=list(map(lambda x: 1 if x==\"T\" else 0,input()))", "S", "list(map(lambda x: 1 if x==\"T\" else 0,input()))", "list", "map(lambda x: 1 if x==\"T\" else 0,input())", "map", "lambda x: 1 if x==\"T\" else 0", "1 if x==\"T\" else 0", "x==\"T\"", "x", "\"T\"", "1", "0", "x", "input()", "input", "q=deque()", "q", "deque()", "deque", "for i in S:\n\n if i:\n if (not q) or q[-1]!=0:\n q.append(i)\n elif q and q[-1]==0:\n q.pop()\n else:\n q.append(i)", "i", "S", "if i:\n if (not q) or q[-1]!=0:\n q.append(i)\n elif q and q[-1]==0:\n q.pop()\n else:\n q.append(i)", "i", "if (not q) or q[-1]!=0:\n q.append(i)\n elif q and q[-1]==0:\n q.pop()\n ", "(not q) or q[-1]!=0", "not q", "q", "q[-1]!=0", "q[-1]", "q", "-1", "0", "q.append(i)", "q.append", "q", "append", "i", "elif q and q[-1]==0:\n q.pop()\n ", "q and q[-1]==0", "q", "q[-1]==0", "q[-1]", "q", "-1", "0", "q.pop()", "q.pop", "q", "pop", "q.append(i)", "q.append", "q", "append", "i", "print(len(q))", "print", "len(q)", "len", "q", "q=deque()", "deque()", "q", "S=list(map(lambda x: 1 if x==\"T\" else 0,input()))", "list(map(lambda x: 1 if x==\"T\" else 0,input()))", "S" ]
from collections import deque S=list(map(lambda x: 1 if x=="T" else 0,input())) q=deque() for i in S: if i: if (not q) or q[-1]!=0: q.append(i) elif q and q[-1]==0: q.pop() else: q.append(i) print(len(q))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 48, 2 ], [ 54, 6 ], [ 49, 9 ], [ 39, 11 ], [ 15, 14 ], [ 49, 17 ], [ 14, 20 ], [ 42, 23 ], [ 40, 27 ], [ 52, 27 ], [ 43, 27 ], [ 51, 30 ], [ 45, 33 ], [ 46, 37 ], [ 55, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ] ]
[ "x=input()\n\nl=len(x)\nstock=0\n\nfor i in list(x):\n if i=='S':\n stock+=1\n else:\n if stock>0:\n stock-=1\n l-=2\n\nprint(l)", "x=input()", "x", "input()", "input", "l=len(x)", "l", "len(x)", "len", "x", "stock=0", "stock", "0", "for i in list(x):\n if i=='S':\n stock+=1\n else:\n if stock>0:\n stock-=1\n l-=2", "i", "list(x)", "list", "x", "if i=='S':\n stock+=1\n else:\n if stock>0:\n stock-=1\n l-=2", "i=='S'", "i", "'S'", "stock+=1", "stock", "1", "if stock>0:\n stock-=1\n l-=2", "stock>0", "stock", "0", "stock-=1", "stock", "1", "l-=2", "l", "2", "print(l)", "print", "l", "stock=0", "0", "stock", "stock+=1", "1", "stock", "l-=2", "2", "l", "x=input()", "input()", "x", "stock-=1", "1", "stock", "l=len(x)", "len(x)", "l" ]
x=input() l=len(x) stock=0 for i in list(x): if i=='S': stock+=1 else: if stock>0: stock-=1 l-=2 print(l)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 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, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 51, 2 ], [ 54, 6 ], [ 52, 9 ], [ 48, 11 ], [ 42, 14 ], [ 18, 17 ], [ 52, 17 ], [ 17, 21 ], [ 45, 24 ], [ 49, 28 ], [ 61, 28 ], [ 46, 28 ], [ 57, 31 ], [ 60, 34 ], [ 58, 39 ], [ 43, 39 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "X = input()\nN = len(X)\ncnt = 0\nans = 0\nfor x in X:\n if x == \"S\":\n cnt += 1\n else:\n if cnt == 0:\n ans += 1\n else:\n cnt -= 1\n\nprint(ans * 2)", "X = input()", "X", "input()", "input", "N = len(X)", "N", "len(X)", "len", "X", "cnt = 0", "cnt", "0", "ans = 0", "ans", "0", "for x in X:\n if x == \"S\":\n cnt += 1\n else:\n if cnt == 0:\n ans += 1\n else:\n cnt -= 1", "x", "X", "if x == \"S\":\n cnt += 1\n else:\n if cnt == 0:\n ans += 1\n else:\n cnt -= 1", "x == \"S\"", "x", "\"S\"", "cnt += 1", "cnt", "1", "if cnt == 0:\n ans += 1\n else:\n cnt -= 1", "cnt == 0", "cnt", "0", "ans += 1", "ans", "1", "cnt -= 1", "cnt", "1", "print(ans * 2)", "print", "ans * 2", "ans", "2", "ans = 0", "0", "ans", "cnt += 1", "1", "cnt", "cnt = 0", "0", "cnt", "X = input()", "input()", "X", "N = len(X)", "len(X)", "N", "ans += 1", "1", "ans", "cnt -= 1", "1", "cnt" ]
X = input() N = len(X) cnt = 0 ans = 0 for x in X: if x == "S": cnt += 1 else: if cnt == 0: ans += 1 else: cnt -= 1 print(ans * 2)
[ 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, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 57, 2 ], [ 42, 6 ], [ 45, 9 ], [ 13, 12 ], [ 58, 17 ], [ 58, 21 ], [ 12, 22 ], [ 51, 25 ], [ 48, 28 ], [ 54, 31 ], [ 43, 34 ], [ 55, 34 ], [ 49, 35 ], [ 52, 35 ], [ 46, 35 ], [ 55, 39 ], [ 43, 39 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "X=input()\n\nans=0\na=0\nfor i in range(len(X)):\n if(X[i]==\"T\"):\n a+=1\n else:\n a-=1\n ans=max(ans,a)\nprint(ans*2)", "X=input()", "X", "input()", "input", "ans=0", "ans", "0", "a=0", "a", "0", "for i in range(len(X)):\n if(X[i]==\"T\"):\n a+=1\n else:\n a-=1\n ans=max(ans,a)", "i", "range(len(X))", "range", "len(X)", "len", "X", "if(X[i]==\"T\"):\n a+=1\n else:\n a-=1\n ", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "a+=1", "a", "1", "a-=1", "a", "1", "ans=max(ans,a)", "ans", "max(ans,a)", "max", "ans", "a", "print(ans*2)", "print", "ans*2", "ans", "2", "ans=0", "0", "ans", "a=0", "0", "a", "a-=1", "1", "a", "a+=1", "1", "a", "ans=max(ans,a)", "max(ans,a)", "ans", "X=input()", "input()", "X" ]
X=input() ans=0 a=0 for i in range(len(X)): if(X[i]=="T"): a+=1 else: a-=1 ans=max(ans,a) print(ans*2)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 13, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 57, 2 ], [ 60, 6 ], [ 69, 9 ], [ 13, 12 ], [ 58, 17 ], [ 70, 20 ], [ 67, 20 ], [ 64, 20 ], [ 79, 20 ], [ 58, 25 ], [ 12, 26 ], [ 75, 29 ], [ 78, 32 ], [ 58, 37 ], [ 12, 38 ], [ 63, 41 ], [ 66, 44 ], [ 67, 48 ], [ 64, 48 ], [ 79, 48 ], [ 70, 48 ], [ 72, 51 ], [ 67, 52 ], [ 64, 52 ], [ 79, 52 ], [ 70, 52 ], [ 73, 55 ], [ 76, 55 ], [ 61, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 67, 72 ], [ 64, 72 ], [ 79, 72 ], [ 70, 72 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "x = input()\n\nans = 0\ns_cnt = 0\n\nfor i in range(len(x)):\n if s_cnt == 0:\n if x[i] == 'T':\n ans += 1\n else:\n s_cnt += 1\n else:\n if x[i] == 'T':\n s_cnt -= 1\n else:\n s_cnt += 1\n\nif s_cnt > 0:\n ans += s_cnt\n\nprint(ans)", "x = input()", "x", "input()", "input", "ans = 0", "ans", "0", "s_cnt = 0", "s_cnt", "0", "for i in range(len(x)):\n if s_cnt == 0:\n if x[i] == 'T':\n ans += 1\n else:\n s_cnt += 1\n else:\n if x[i] == 'T':\n s_cnt -= 1\n else:\n s_cnt += 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if s_cnt == 0:\n if x[i] == 'T':\n ans += 1\n else:\n s_cnt += 1\n else:\n if x[i] == 'T':\n s_cnt -= 1\n else:\n s_cnt += 1", "s_cnt == 0", "s_cnt", "0", "if x[i] == 'T':\n ans += 1\n else:\n s_cnt += 1\n ", "x[i] == 'T'", "x[i]", "x", "i", "'T'", "ans += 1", "ans", "1", "s_cnt += 1", "s_cnt", "1", "if x[i] == 'T':\n s_cnt -= 1\n else:\n s_cnt += 1", "x[i] == 'T'", "x[i]", "x", "i", "'T'", "s_cnt -= 1", "s_cnt", "1", "s_cnt += 1", "s_cnt", "1", "if s_cnt > 0:\n ans += s_cnt", "s_cnt > 0", "s_cnt", "0", "ans += s_cnt", "ans", "s_cnt", "print(ans)", "print", "ans", "x = input()", "input()", "x", "ans = 0", "0", "ans", "s_cnt -= 1", "1", "s_cnt", "s_cnt += 1", "1", "s_cnt", "s_cnt = 0", "0", "s_cnt", "ans += s_cnt", "s_cnt", "ans", "ans += 1", "1", "ans", "s_cnt += 1", "1", "s_cnt" ]
x = input() ans = 0 s_cnt = 0 for i in range(len(x)): if s_cnt == 0: if x[i] == 'T': ans += 1 else: s_cnt += 1 else: if x[i] == 'T': s_cnt -= 1 else: s_cnt += 1 if s_cnt > 0: ans += s_cnt print(ans)
[ 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, 4, 13, 17, 2, 13, 17, 0, 13, 17, 14, 2, 18, 13, 2, 40, 13, 17, 17, 0, 13, 4, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 76, 2 ], [ 79, 6 ], [ 73, 9 ], [ 13, 12 ], [ 77, 17 ], [ 77, 21 ], [ 12, 22 ], [ 61, 25 ], [ 80, 30 ], [ 68, 30 ], [ 62, 30 ], [ 67, 33 ], [ 77, 38 ], [ 12, 41 ], [ 64, 45 ], [ 74, 50 ], [ 71, 50 ], [ 65, 50 ], [ 70, 53 ], [ 68, 58 ], [ 62, 58 ], [ 80, 58 ], [ 71, 59 ], [ 65, 59 ], [ 74, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ] ]
[ "x = input()\ns = 0\nt = 0\nfor i in range(len(x)):\n if x[i] == \"T\":\n s = max(0, s-1)\n else:\n s += 1\n if x[-i-1] == \"S\":\n t = max(0, t -1)\n else:\n t += 1\nprint(s+t)", "x = input()", "x", "input()", "input", "s = 0", "s", "0", "t = 0", "t", "0", "for i in range(len(x)):\n if x[i] == \"T\":\n s = max(0, s-1)\n else:\n s += 1\n if x[-i-1] == \"S\":\n t = max(0, t -1)\n else:\n t += 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == \"T\":\n s = max(0, s-1)\n else:\n s += 1\n ", "x[i] == \"T\"", "x[i]", "x", "i", "\"T\"", "s = max(0, s-1)", "s", "max(0, s-1)", "max", "0", "s-1", "s", "1", "s += 1", "s", "1", "if x[-i-1] == \"S\":\n t = max(0, t -1)\n else:\n t += 1", "x[-i-1] == \"S\"", "x[-i-1]", "x", "-i-1", "-i", "i", "1", "\"S\"", "t = max(0, t -1)", "t", "max(0, t -1)", "max", "0", "t -1", "t", "1", "t += 1", "t", "1", "print(s+t)", "print", "s+t", "s", "t", "s = max(0, s-1)", "max(0, s-1)", "s", "t = max(0, t -1)", "max(0, t -1)", "t", "s += 1", "1", "s", "t += 1", "1", "t", "t = 0", "0", "t", "x = input()", "input()", "x", "s = 0", "0", "s" ]
x = input() s = 0 t = 0 for i in range(len(x)): if x[i] == "T": s = max(0, s-1) else: s += 1 if x[-i-1] == "S": t = max(0, t -1) else: t += 1 print(s+t)
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 15, 15, 12, 13, 29, 18, 4, 18, 18, 13, 13, 13, 39, 17, 12, 13, 29, 2, 39, 17, 4, 13, 4, 13, 13, 23, 13, 4, 18, 13, 13, 17, 0, 13, 2, 4, 13, 17, 17, 17, 41, 28, 13, 4, 13, 17, 4, 4, 13, 2, 4, 13, 17, 13, 0, 13, 13, 0, 13, 39, 39, 17, 17, 39, 17, 17, 39, 17, 17, 39, 17, 17, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 18, 4, 13, 4, 13, 13, 39, 17, 14, 2, 18, 13, 13, 17, 0, 13, 2, 13, 17, 3, 0, 13, 4, 13, 13, 28, 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, 13, 10, 2, 13, 10, 2, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 38, 36 ], [ 38, 38 ], [ 152, 45 ], [ 55, 54 ], [ 54, 65 ], [ 179, 67 ], [ 155, 70 ], [ 158, 85 ], [ 171, 87 ], [ 167, 89 ], [ 182, 92 ], [ 96, 95 ], [ 159, 101 ], [ 159, 107 ], [ 95, 108 ], [ 149, 111 ], [ 95, 113 ], [ 161, 117 ], [ 159, 120 ], [ 123, 122 ], [ 150, 125 ], [ 183, 125 ], [ 159, 129 ], [ 122, 130 ], [ 173, 133 ], [ 168, 137 ], [ 186, 137 ], [ 174, 137 ], [ 185, 140 ], [ 164, 143 ], [ 165, 147 ], [ 162, 147 ], [ 149, 150 ], [ 152, 153 ], [ 155, 156 ], [ 158, 159 ], [ 161, 162 ], [ 164, 165 ], [ 167, 168 ], [ 173, 174 ], [ 179, 180 ], [ 182, 183 ], [ 185, 186 ] ]
[ "import bisect\nimport copy\nimport heapq\nimport math\nimport sys\nfrom collections import *\nfrom functools import lru_cache\nfrom itertools import accumulate, combinations, permutations, product\ndef input():\n return sys.stdin.readline()[:-1]\ndef ruiseki(lst):\n return [0]+list(accumulate(lst))\nsys.setrecursionlimit(500000)\nmod=pow(10,9)+7\nal=[chr(ord('a') + i) for i in range(26)]\ndirection=[[1,0],[0,1],[-1,0],[0,-1]]\n\nx=input()\n\nscnt=0\nm=0\nfor i in range(len(x))[::-1]:\n if x[i]==\"T\":\n m=i+1\n break\n\nans=len(x)\nfor i in range(m):\n if x[i]==\"S\":\n scnt+=1\n else:\n if scnt>0:\n scnt-=1\n ans-=2\n # print(scnt)\nprint(ans)", "import bisect", "bisect", "import copy", "copy", "import heapq", "heapq", "import math", "math", "import sys", "sys", "from collections import *", "from functools import lru_cache", "from itertools import accumulate, combinations, permutations, product", "def input():\n return sys.stdin.readline()[:-1]", "input", "return sys.stdin.readline()[:-1]", "sys.stdin.readline()[:-1]", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", ":-1", "-1", "def ruiseki(lst):\n return [0]+list(accumulate(lst))", "ruiseki", "return [0]+list(accumulate(lst))", "[0]+list(accumulate(lst))", "[0]", "0", "list(accumulate(lst))", "list", "accumulate(lst)", "accumulate", "lst", "lst", "lst", "sys.setrecursionlimit(500000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "500000", "mod=pow(10,9)+7", "mod", "pow(10,9)+7", "pow(10,9)", "pow", "10", "9", "7", "chr(ord('a') + i) for i in range(26)", "for i in range(26)", "i", "range(26)", "range", "26", "for i in range(26)", "chr(ord('a') + i)", "chr", "ord('a') + i", "ord('a')", "ord", "'a'", "i", "al=[chr(ord('a') + i) for i in range(26)]", "al", "[chr(ord('a') + i) for i in range(26)]", "direction=[[1,0],[0,1],[-1,0],[0,-1]]", "direction", "[[1,0],[0,1],[-1,0],[0,-1]]", "[1,0]", "1", "0", "[0,1]", "0", "1", "[-1,0]", "-1", "0", "[0,-1]", "0", "-1", "x=input()", "x", "input()", "input", "scnt=0", "scnt", "0", "m=0", "m", "0", "for i in range(len(x))[::-1]:\n if x[i]==\"T\":\n m=i+1\n break", "i", "range(len(x))[::-1]", "(len(x))", "range", "len(x)", "len", "x", "::-1", "-1", "if x[i]==\"T\":\n m=i+1\n break", "x[i]==\"T\"", "x[i]", "x", "i", "\"T\"", "m=i+1", "m", "i+1", "i", "1", "break", "ans=len(x)", "ans", "len(x)", "len", "x", "for i in range(m):\n if x[i]==\"S\":\n scnt+=1\n else:\n if scnt>0:\n scnt-=1\n ans-=2\n # print(scnt)", "i", "range(m)", "range", "m", "if x[i]==\"S\":\n scnt+=1\n else:\n if scnt>0:\n scnt-=1\n ans-=2\n # print(scnt)", "x[i]==\"S\"", "x[i]", "x", "i", "\"S\"", "scnt+=1", "scnt", "1", "if scnt>0:\n scnt-=1\n ans-=2\n # print(scnt)", "scnt>0", "scnt", "0", "scnt-=1", "scnt", "1", "ans-=2", "ans", "2", "print(ans)", "print", "ans", "m=i+1", "i+1", "m", "mod=pow(10,9)+7", "pow(10,9)+7", "mod", "direction=[[1,0],[0,1],[-1,0],[0,-1]]", "[[1,0],[0,1],[-1,0],[0,-1]]", "direction", "x=input()", "input()", "x", "ans=len(x)", "len(x)", "ans", "ans-=2", "2", "ans", "scnt=0", "0", "scnt", "def input():\n return sys.stdin.readline()[:-1]", "def input():\n return sys.stdin.readline()[:-1]", "input", "scnt+=1", "1", "scnt", "def ruiseki(lst):\n return [0]+list(accumulate(lst))", "def ruiseki(lst):\n return [0]+list(accumulate(lst))", "ruiseki", "al=[chr(ord('a') + i) for i in range(26)]", "[chr(ord('a') + i) for i in range(26)]", "al", "m=0", "0", "m", "scnt-=1", "1", "scnt" ]
import bisect import copy import heapq import math import sys from collections import * from functools import lru_cache from itertools import accumulate, combinations, permutations, product def input(): return sys.stdin.readline()[:-1] def ruiseki(lst): return [0]+list(accumulate(lst)) sys.setrecursionlimit(500000) mod=pow(10,9)+7 al=[chr(ord('a') + i) for i in range(26)] direction=[[1,0],[0,1],[-1,0],[0,-1]] x=input() scnt=0 m=0 for i in range(len(x))[::-1]: if x[i]=="T": m=i+1 break ans=len(x) for i in range(m): if x[i]=="S": scnt+=1 else: if scnt>0: scnt-=1 ans-=2 # print(scnt) print(ans)
[ 7, 15, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 18, 13, 13, 0, 13, 12, 4, 13, 4, 13, 0, 13, 12, 4, 13, 4, 13, 13, 4, 18, 4, 18, 13, 13, 13, 0, 13, 12, 4, 18, 4, 18, 13, 13, 13, 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, 4, 13, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 2, 13, 10, 18, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13 ]
[ [ 121, 23 ], [ 130, 28 ], [ 124, 35 ], [ 118, 40 ], [ 139, 47 ], [ 125, 58 ], [ 136, 62 ], [ 125, 68 ], [ 127, 72 ], [ 137, 74 ], [ 112, 76 ], [ 142, 79 ], [ 83, 82 ], [ 128, 82 ], [ 82, 86 ], [ 109, 89 ], [ 113, 93 ], [ 134, 93 ], [ 110, 93 ], [ 133, 96 ], [ 115, 99 ], [ 128, 106 ], [ 116, 107 ], [ 143, 107 ], [ 109, 110 ], [ 112, 113 ], [ 115, 116 ], [ 118, 119 ], [ 121, 122 ], [ 124, 125 ], [ 127, 128 ], [ 130, 131 ], [ 133, 134 ], [ 136, 137 ], [ 139, 140 ], [ 142, 143 ] ]
[ "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nx = ns()\nct = 0\nans = 0\nfor c in x:\n if c == 'S':\n ct += 1\n else:\n if ct > 0:\n ct -= 1\n ans += 2\nprint(len(x)-ans)", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy", "math", "string", "itertools", "fractions", "heapq", "collections", "re", "array", "bisect", "sys", "random", "time", "copy", "sys.setrecursionlimit(10**7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**7", "10", "7", "inf = 10**20", "inf", "10**20", "10", "20", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "stdin = sys.stdin", "stdin", "sys.stdin", "sys", "stdin", "ni = lambda: int(ns())", "ni", "lambda: int(ns())", "int(ns())", "int", "ns()", "ns", "na = lambda: list(map(int, stdin.readline().split()))", "na", "lambda: list(map(int, stdin.readline().split()))", "list(map(int, stdin.readline().split()))", "list", "map(int, stdin.readline().split())", "map", "int", "stdin.readline().split()", "stdin.readline().split", "stdin.readline()", "stdin.readline", "stdin", "readline", "split", "ns = lambda: stdin.readline().rstrip()", "ns", "lambda: stdin.readline().rstrip()", "stdin.readline().rstrip()", "stdin.readline().rstrip", "stdin.readline()", "stdin.readline", "stdin", "readline", "rstrip", "x = ns()", "x", "ns()", "ns", "ct = 0", "ct", "0", "ans = 0", "ans", "0", "for c in x:\n if c == 'S':\n ct += 1\n else:\n if ct > 0:\n ct -= 1\n ans += 2", "c", "x", "if c == 'S':\n ct += 1\n else:\n if ct > 0:\n ct -= 1\n ans += 2", "c == 'S'", "c", "'S'", "ct += 1", "ct", "1", "if ct > 0:\n ct -= 1\n ans += 2", "ct > 0", "ct", "0", "ct -= 1", "ct", "1", "ans += 2", "ans", "2", "print(len(x)-ans)", "print", "len(x)-ans", "len(x)", "len", "x", "ans", "ct += 1", "1", "ct", "ct = 0", "0", "ct", "ans += 2", "2", "ans", "ni = lambda: int(ns())", "lambda: int(ns())", "ni", "inf = 10**20", "10**20", "inf", "stdin = sys.stdin", "sys.stdin", "stdin", "x = ns()", "ns()", "x", "mod = 10**9 + 7", "10**9 + 7", "mod", "ct -= 1", "1", "ct", "ns = lambda: stdin.readline().rstrip()", "lambda: stdin.readline().rstrip()", "ns", "na = lambda: list(map(int, stdin.readline().split()))", "lambda: list(map(int, stdin.readline().split()))", "na", "ans = 0", "0", "ans" ]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() # ignore trailing spaces x = ns() ct = 0 ans = 0 for c in x: if c == 'S': ct += 1 else: if ct > 0: ct -= 1 ans += 2 print(len(x)-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, 13, 4, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 47, 2 ], [ 41, 6 ], [ 59, 9 ], [ 53, 12 ], [ 16, 15 ], [ 48, 15 ], [ 15, 19 ], [ 62, 22 ], [ 42, 26 ], [ 45, 26 ], [ 63, 26 ], [ 50, 29 ], [ 44, 32 ], [ 56, 35 ], [ 45, 36 ], [ 63, 36 ], [ 42, 36 ], [ 57, 39 ], [ 51, 39 ], [ 54, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 45, 56 ], [ 63, 56 ], [ 42, 56 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "seq=input()\n\ns=0\nt=0\nc=0\n\nfor si in seq:\n if si==\"S\":\n s+=1\n else:\n if s==0:\n c+=1\n else:\n s-=1\nc+=s\n\nprint(c)", "seq=input()", "seq", "input()", "input", "s=0", "s", "0", "t=0", "t", "0", "c=0", "c", "0", "for si in seq:\n if si==\"S\":\n s+=1\n else:\n if s==0:\n c+=1\n else:\n s-=1", "si", "seq", "if si==\"S\":\n s+=1\n else:\n if s==0:\n c+=1\n else:\n s-=1", "si==\"S\"", "si", "\"S\"", "s+=1", "s", "1", "if s==0:\n c+=1\n else:\n s-=1", "s==0", "s", "0", "c+=1", "c", "1", "s-=1", "s", "1", "c+=s", "c", "s", "print(c)", "print", "c", "s=0", "0", "s", "s-=1", "1", "s", "seq=input()", "input()", "seq", "c+=1", "1", "c", "c=0", "0", "c", "c+=s", "s", "c", "t=0", "0", "t", "s+=1", "1", "s" ]
seq=input() s=0 t=0 c=0 for si in seq: if si=="S": s+=1 else: if s==0: c+=1 else: s-=1 c+=s print(c)
[ 7, 0, 13, 4, 13, 0, 13, 17, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 47, 2 ], [ 41, 6 ], [ 35, 8 ], [ 12, 11 ], [ 48, 11 ], [ 11, 15 ], [ 50, 18 ], [ 38, 21 ], [ 44, 24 ], [ 42, 27 ], [ 45, 27 ], [ 39, 28 ], [ 51, 28 ], [ 36, 28 ], [ 45, 32 ], [ 42, 32 ], [ 35, 36 ], [ 38, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ] ]
[ "X = input()\nans, sc = 0, 0\nfor x in X:\n if x == 'T':\n sc += 1\n else:\n sc -= 1\n ans = max(ans, sc)\nprint(ans*2)", "X = input()", "X", "input()", "input", "ans, sc = 0, 0", "ans", "0", "sc", "0", "for x in X:\n if x == 'T':\n sc += 1\n else:\n sc -= 1\n ans = max(ans, sc)", "x", "X", "if x == 'T':\n sc += 1\n else:\n sc -= 1\n ", "x == 'T'", "x", "'T'", "sc += 1", "sc", "1", "sc -= 1", "sc", "1", "ans = max(ans, sc)", "ans", "max(ans, sc)", "max", "ans", "sc", "print(ans*2)", "print", "ans*2", "ans", "2", "sc = 0, 0", "0", "sc", "sc -= 1", "1", "sc", "ans, sc = 0, 0", "0", "ans", "ans = max(ans, sc)", "max(ans, sc)", "ans", "X = input()", "input()", "X", "sc += 1", "1", "sc" ]
X = input() ans, sc = 0, 0 for x in X: if x == 'T': sc += 1 else: sc -= 1 ans = max(ans, sc) 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, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 64, 2 ], [ 55, 8 ], [ 52, 11 ], [ 15, 14 ], [ 65, 19 ], [ 65, 23 ], [ 14, 24 ], [ 49, 27 ], [ 56, 31 ], [ 59, 31 ], [ 50, 31 ], [ 58, 34 ], [ 61, 37 ], [ 65, 44 ], [ 62, 47 ], [ 53, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "x = list(input())\nsta = 0\npop = 0\nfor i in range(len(x)):\n if x[i] == 'S':\n sta += 1\n elif sta > 0:\n sta -= 1\n pop += 1\nprint(len(x)-2*pop)", "x = list(input())", "x", "list(input())", "list", "input()", "input", "sta = 0", "sta", "0", "pop = 0", "pop", "0", "for i in range(len(x)):\n if x[i] == 'S':\n sta += 1\n elif sta > 0:\n sta -= 1\n pop += 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == 'S':\n sta += 1\n elif sta > 0:\n sta -= 1\n pop += 1", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "sta += 1", "sta", "1", "elif sta > 0:\n sta -= 1\n pop += 1", "sta > 0", "sta", "0", "sta -= 1", "sta", "1", "pop += 1", "pop", "1", "print(len(x)-2*pop)", "print", "len(x)-2*pop", "len(x)", "len", "x", "2*pop", "2", "pop", "sta += 1", "1", "sta", "pop = 0", "0", "pop", "sta = 0", "0", "sta", "sta -= 1", "1", "sta", "pop += 1", "1", "pop", "x = list(input())", "list(input())", "x" ]
x = list(input()) sta = 0 pop = 0 for i in range(len(x)): if x[i] == 'S': sta += 1 elif sta > 0: sta -= 1 pop += 1 print(len(x)-2*pop)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 2, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 2, 13, 17, 14, 2, 13, 17, 0, 13, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 4, 13, 17, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 82, 2 ], [ 67, 6 ], [ 83, 9 ], [ 76, 11 ], [ 85, 14 ], [ 88, 17 ], [ 21, 20 ], [ 68, 23 ], [ 83, 27 ], [ 20, 28 ], [ 79, 31 ], [ 86, 33 ], [ 74, 33 ], [ 71, 33 ], [ 80, 33 ], [ 83, 38 ], [ 20, 39 ], [ 70, 42 ], [ 80, 44 ], [ 86, 44 ], [ 74, 44 ], [ 71, 44 ], [ 71, 48 ], [ 80, 48 ], [ 86, 48 ], [ 74, 48 ], [ 91, 51 ], [ 89, 53 ], [ 92, 53 ], [ 73, 56 ], [ 92, 61 ], [ 89, 61 ], [ 74, 65 ], [ 71, 65 ], [ 80, 65 ], [ 86, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ] ]
[ "X=input()\nN=len(X)\ncnt=0\nsptm=0\nans=0\nfor i in range(N):\n if X[i]==\"S\":\n sptm=sptm+1\n if X[i]==\"T\":\n sptm=sptm-1\n if sptm<0:\n ans=ans+1\n sptm=0\n #print(sptm,ans)\nprint(ans+max(0,sptm))", "X=input()", "X", "input()", "input", "N=len(X)", "N", "len(X)", "len", "X", "cnt=0", "cnt", "0", "sptm=0", "sptm", "0", "ans=0", "ans", "0", "for i in range(N):\n if X[i]==\"S\":\n sptm=sptm+1\n if X[i]==\"T\":\n sptm=sptm-1\n if sptm<0:\n ans=ans+1\n sptm=0\n #print(sptm,ans)", "i", "range(N)", "range", "N", "if X[i]==\"S\":\n sptm=sptm+1\n ", "X[i]==\"S\"", "X[i]", "X", "i", "\"S\"", "sptm=sptm+1", "sptm", "sptm+1", "sptm", "1", "if X[i]==\"T\":\n sptm=sptm-1\n ", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "sptm=sptm-1", "sptm", "sptm-1", "sptm", "1", "if sptm<0:\n ans=ans+1\n sptm=0\n #print(sptm,ans)", "sptm<0", "sptm", "0", "ans=ans+1", "ans", "ans+1", "ans", "1", "sptm=0", "sptm", "0", "print(ans+max(0,sptm))", "print", "ans+max(0,sptm)", "ans", "max(0,sptm)", "max", "0", "sptm", "N=len(X)", "len(X)", "N", "sptm=sptm-1", "sptm-1", "sptm", "sptm=0", "0", "sptm", "cnt=0", "0", "cnt", "sptm=sptm+1", "sptm+1", "sptm", "X=input()", "input()", "X", "sptm=0", "0", "sptm", "ans=0", "0", "ans", "ans=ans+1", "ans+1", "ans" ]
X=input() N=len(X) cnt=0 sptm=0 ans=0 for i in range(N): if X[i]=="S": sptm=sptm+1 if X[i]=="T": sptm=sptm-1 if sptm<0: ans=ans+1 sptm=0 #print(sptm,ans) print(ans+max(0,sptm))
[ 7, 0, 13, 4, 13, 0, 13, 17, 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 36, 2 ], [ 42, 6 ], [ 39, 8 ], [ 37, 11 ], [ 14, 13 ], [ 37, 13 ], [ 13, 17 ], [ 45, 20 ], [ 43, 24 ], [ 52, 24 ], [ 46, 24 ], [ 51, 27 ], [ 48, 30 ], [ 49, 34 ], [ 40, 34 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "s=input()\ncnt,ans=0,len(s)\nfor ss in s:\n if ss==\"S\":\n cnt+=1\n else:\n if cnt>0:\n cnt-=1\n ans-=2\nprint(ans)", "s=input()", "s", "input()", "input", "cnt,ans=0,len(s)", "cnt", "0", "ans", "len(s)", "len", "s", "for ss in s:\n if ss==\"S\":\n cnt+=1\n else:\n if cnt>0:\n cnt-=1\n ans-=2", "ss", "s", "if ss==\"S\":\n cnt+=1\n else:\n if cnt>0:\n cnt-=1\n ans-=2", "ss==\"S\"", "ss", "\"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(ans)", "print", "ans", "s=input()", "input()", "s", "ans=0,len(s)", "len(s)", "ans", "cnt,ans=0,len(s)", "0", "cnt", "cnt+=1", "1", "cnt", "ans-=2", "2", "ans", "cnt-=1", "1", "cnt" ]
s=input() cnt,ans=0,len(s) for ss in s: if ss=="S": cnt+=1 else: if cnt>0: cnt-=1 ans-=2 print(ans)
[ 7, 15, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 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, 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, 12, 13, 10, 18, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 93, 4 ], [ 32, 31 ], [ 91, 33 ], [ 36, 35 ], [ 39, 38 ], [ 42, 41 ], [ 31, 41 ], [ 41, 45 ], [ 49, 48 ], [ 38, 52 ], [ 58, 52 ], [ 48, 52 ], [ 56, 55 ], [ 59, 58 ], [ 55, 63 ], [ 35, 63 ], [ 58, 64 ], [ 48, 64 ], [ 38, 64 ], [ 85, 70 ], [ 93, 94 ] ]
[ "import sys\ninput = sys.stdin.buffer.readline\n\n#sys.setrecursionlimit(10**9)\n#from functools import lru_cache\n\ndef RD(): return input().rstrip().decode()\ndef II(): return int(input())\ndef FI(): return int(input())\ndef MI(): return map(int,input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int,input().split()))\ndef LF(): return list(map(float,input().split()))\ndef TI(): return tuple(map(int,input().split()))\n# rstrip().decode()\n\ndef main():\n\tx=RD()\n\n\tans=0\n\ts=0\n\n\tfor i in x:\n\t\tif i==\"S\":\n\t\t\ts+=1\n\t\telse:\n\t\t\tif s==0:\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\ts-=1\n\n\tprint(ans+s)\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n\tmain()", "import sys", "sys", "input = sys.stdin.buffer.readline", "input", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "def RD(): return input().rstrip().decode()", "RD", "def II(): return int(input())", "II", "def FI(): return int(input())", "FI", "def MI(): return map(int,input().split())", "MI", "def MF(): return map(float,input().split())", "MF", "def LI(): return list(map(int,input().split()))", "LI", "def LF(): return list(map(float,input().split()))", "LF", "def TI(): return tuple(map(int,input().split()))\n# rstrip().decode()", "TI", "def main():\n\tx=RD()\n\n\tans=0\n\ts=0\n\n\tfor i in x:\n\t\tif i==\"S\":\n\t\t\ts+=1\n\t\telse:\n\t\t\tif s==0:\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\ts-=1\n\n\tprint(ans+s)", "main", "x=RD()", "x", "RD()", "RD", "ans=0", "ans", "0", "s=0", "s", "0", "for i in x:\n\t\tif i==\"S\":\n\t\t\ts+=1\n\t\telse:\n\t\t\tif s==0:\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\ts-=1\n\n\t", "i", "x", "if i==\"S\":\n\t\t\ts+=1\n\t\telse:\n\t\t\tif s==0:\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\ts-=1\n\n\t", "i==\"S\"", "i", "\"S\"", "s+=1", "s", "1", "if s==0:\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\ts-=1\n\n\t", "s==0", "s", "0", "ans+=1", "ans", "1", "s-=1", "s", "1", "print(ans+s)", "print", "ans+s", "ans", "s", "if __name__ == \"__main__\":\n\tmain()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def TI(): return tuple(map(int,input().split()))\n# rstrip().decode()", "def TI(): return tuple(map(int,input().split()))\n# rstrip().decode()", "TI", "def II(): return int(input())", "def II(): return int(input())", "II", "def MI(): return map(int,input().split())", "def MI(): return map(int,input().split())", "MI", "def LF(): return list(map(float,input().split()))", "def LF(): return list(map(float,input().split()))", "LF", "def main():\n\tx=RD()\n\n\tans=0\n\ts=0\n\n\tfor i in x:\n\t\tif i==\"S\":\n\t\t\ts+=1\n\t\telse:\n\t\t\tif s==0:\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\ts-=1\n\n\tprint(ans+s)", "def main():\n\tx=RD()\n\n\tans=0\n\ts=0\n\n\tfor i in x:\n\t\tif i==\"S\":\n\t\t\ts+=1\n\t\telse:\n\t\t\tif s==0:\n\t\t\t\tans+=1\n\t\t\telse:\n\t\t\t\ts-=1\n\n\tprint(ans+s)", "main", "def MF(): return map(float,input().split())", "def MF(): return map(float,input().split())", "MF", "def RD(): return input().rstrip().decode()", "def RD(): return input().rstrip().decode()", "RD", "input = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "input", "def FI(): return int(input())", "def FI(): return int(input())", "FI", "def LI(): return list(map(int,input().split()))", "def LI(): return list(map(int,input().split()))", "LI" ]
import sys input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return input().rstrip().decode() def II(): return int(input()) def FI(): return int(input()) def MI(): return map(int,input().split()) def MF(): return map(float,input().split()) def LI(): return list(map(int,input().split())) def LF(): return list(map(float,input().split())) def TI(): return tuple(map(int,input().split())) # rstrip().decode() def main(): x=RD() ans=0 s=0 for i in x: if i=="S": s+=1 else: if s==0: ans+=1 else: s-=1 print(ans+s) if __name__ == "__main__": main()
[ 7, 0, 13, 4, 13, 0, 13, 17, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 40, 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, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 55, 2 ], [ 49, 6 ], [ 58, 8 ], [ 12, 11 ], [ 56, 16 ], [ 56, 20 ], [ 11, 21 ], [ 46, 24 ], [ 50, 28 ], [ 53, 28 ], [ 47, 28 ], [ 52, 31 ], [ 61, 34 ], [ 56, 41 ], [ 62, 44 ], [ 59, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "X = input()\ns_cnt, t_cnt = 0, 0\nfor i in range(len(X)):\n if X[i] == \"S\":\n s_cnt += 1\n elif s_cnt != 0:\n s_cnt -= 1\n t_cnt += 1\nprint(len(X) - 2*t_cnt)", "X = input()", "X", "input()", "input", "s_cnt, t_cnt = 0, 0", "s_cnt", "0", "t_cnt", "0", "for i in range(len(X)):\n if X[i] == \"S\":\n s_cnt += 1\n elif s_cnt != 0:\n s_cnt -= 1\n t_cnt += 1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == \"S\":\n s_cnt += 1\n elif s_cnt != 0:\n s_cnt -= 1\n t_cnt += 1", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "s_cnt += 1", "s_cnt", "1", "elif s_cnt != 0:\n s_cnt -= 1\n t_cnt += 1", "s_cnt != 0", "s_cnt", "0", "s_cnt -= 1", "s_cnt", "1", "t_cnt += 1", "t_cnt", "1", "print(len(X) - 2*t_cnt)", "print", "len(X) - 2*t_cnt", "len(X)", "len", "X", "2*t_cnt", "2", "t_cnt", "s_cnt += 1", "1", "s_cnt", "s_cnt, t_cnt = 0, 0", "0", "s_cnt", "s_cnt -= 1", "1", "s_cnt", "X = input()", "input()", "X", "t_cnt = 0, 0", "0", "t_cnt", "t_cnt += 1", "1", "t_cnt" ]
X = input() s_cnt, t_cnt = 0, 0 for i in range(len(X)): if X[i] == "S": s_cnt += 1 elif s_cnt != 0: s_cnt -= 1 t_cnt += 1 print(len(X) - 2*t_cnt)
[ 7, 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, 2, 13, 17, 13, 4, 18, 13, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 39, 13 ]
[ [ 42, 2 ], [ 45, 6 ], [ 43, 9 ], [ 51, 11 ], [ 15, 14 ], [ 43, 14 ], [ 14, 18 ], [ 52, 22 ], [ 43, 24 ], [ 14, 28 ], [ 52, 30 ], [ 52, 33 ], [ 48, 36 ], [ 49, 40 ], [ 46, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "# https://atcoder.jp/contests/agc005/tasks/agc005_a\n\nS = input()\nret = len(S)\nstack = []\nfor s in S:\n if s == 'S':\n stack.append(S)\n if s == 'T' and stack:\n stack.pop()\n ret -= 2\n\nprint(ret)", "S = input()", "S", "input()", "input", "ret = len(S)", "ret", "len(S)", "len", "S", "stack = []", "stack", "[]", "for s in S:\n if s == 'S':\n stack.append(S)\n if s == 'T' and stack:\n stack.pop()\n ret -= 2", "s", "S", "if s == 'S':\n stack.append(S)\n ", "s == 'S'", "s", "'S'", "stack.append(S)", "stack.append", "stack", "append", "S", "if s == 'T' and stack:\n stack.pop()\n ret -= 2", "s == 'T' and stack", "s == 'T'", "s", "'T'", "stack", "stack.pop()", "stack.pop", "stack", "pop", "ret -= 2", "ret", "2", "print(ret)", "print", "ret", "S = input()", "input()", "S", "ret = len(S)", "len(S)", "ret", "ret -= 2", "2", "ret", "stack = []", "[]", "stack" ]
# https://atcoder.jp/contests/agc005/tasks/agc005_a S = input() ret = len(S) stack = [] for s in S: if s == 'S': stack.append(S) if s == 'T' and stack: stack.pop() ret -= 2 print(ret)