node_ids
sequencelengths
4
1.4k
edge_index
sequencelengths
1
2.22k
text
sequencelengths
4
1.4k
source
stringlengths
14
427k
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 39, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 40, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 18, 13, 13, 4, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 65, 2 ], [ 77, 6 ], [ 66, 9 ], [ 68, 11 ], [ 74, 14 ], [ 18, 17 ], [ 78, 20 ], [ 66, 24 ], [ 17, 25 ], [ 75, 29 ], [ 66, 32 ], [ 17, 33 ], [ 75, 37 ], [ 75, 40 ], [ 75, 45 ], [ 66, 48 ], [ 17, 49 ], [ 75, 52 ], [ 71, 55 ], [ 78, 60 ], [ 72, 62 ], [ 69, 62 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ] ]
[ "x=input()\nl=len(x)\nans=0\nq=[]\nfor i in range(l):\n if x[i]=='S':\n q.append(x[i])\n else:\n if not q or q[-1]=='T':\n q.append(x[i])\n else:\n q.pop()\n ans+=1\nprint(l-ans*2)", "x=input()", "x", "input()", "input", "l=len(x)", "l", "len(x)", "len", "x", "ans=0", "ans", "0", "q=[]", "q", "[]", "for i in range(l):\n if x[i]=='S':\n q.append(x[i])\n else:\n if not q or q[-1]=='T':\n q.append(x[i])\n else:\n q.pop()\n ans+=1", "i", "range(l)", "range", "l", "if x[i]=='S':\n q.append(x[i])\n else:\n if not q or q[-1]=='T':\n q.append(x[i])\n else:\n q.pop()\n ans+=1", "x[i]=='S'", "x[i]", "x", "i", "'S'", "q.append(x[i])", "q.append", "q", "append", "x[i]", "x", "i", "if not q or q[-1]=='T':\n q.append(x[i])\n else:\n q.pop()\n ans+=1", "not q or q[-1]=='T'", "not q", "q", "q[-1]=='T'", "q[-1]", "q", "-1", "'T'", "q.append(x[i])", "q.append", "q", "append", "x[i]", "x", "i", "q.pop()", "q.pop", "q", "pop", "ans+=1", "ans", "1", "print(l-ans*2)", "print", "l-ans*2", "l", "ans*2", "ans", "2", "x=input()", "input()", "x", "ans=0", "0", "ans", "ans+=1", "1", "ans", "q=[]", "[]", "q", "l=len(x)", "len(x)", "l" ]
x=input() l=len(x) ans=0 q=[] for i in range(l): if x[i]=='S': q.append(x[i]) else: if not q or q[-1]=='T': q.append(x[i]) else: q.pop() ans+=1 print(l-ans*2)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 37, 2 ], [ 43, 6 ], [ 38, 9 ], [ 46, 11 ], [ 15, 14 ], [ 38, 14 ], [ 14, 18 ], [ 49, 21 ], [ 47, 25 ], [ 53, 25 ], [ 50, 25 ], [ 52, 28 ], [ 40, 31 ], [ 41, 35 ], [ 44, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "X = input()\nans = len(X)\nsc = 0\nfor x in X:\n if x == \"S\":\n sc += 1\n elif sc > 0:\n sc -= 1\n ans -= 2\nprint(ans)", "X = input()", "X", "input()", "input", "ans = len(X)", "ans", "len(X)", "len", "X", "sc = 0", "sc", "0", "for x in X:\n if x == \"S\":\n sc += 1\n elif sc > 0:\n sc -= 1\n ans -= 2", "x", "X", "if x == \"S\":\n sc += 1\n elif sc > 0:\n sc -= 1\n ans -= 2", "x == \"S\"", "x", "\"S\"", "sc += 1", "sc", "1", "elif sc > 0:\n sc -= 1\n ans -= 2", "sc > 0", "sc", "0", "sc -= 1", "sc", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "X = input()", "input()", "X", "ans -= 2", "2", "ans", "ans = len(X)", "len(X)", "ans", "sc = 0", "0", "sc", "sc += 1", "1", "sc", "sc -= 1", "1", "sc" ]
X = input() ans = len(X) sc = 0 for x in X: if x == "S": sc += 1 elif sc > 0: sc -= 1 ans -= 2 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 37, 2 ], [ 40, 6 ], [ 49, 9 ], [ 13, 12 ], [ 38, 12 ], [ 12, 16 ], [ 52, 19 ], [ 41, 23 ], [ 47, 23 ], [ 53, 23 ], [ 43, 26 ], [ 46, 29 ], [ 44, 34 ], [ 50, 34 ], [ 47, 35 ], [ 53, 35 ], [ 41, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "x = input()\ns=0\nans=0\nfor i in x:\n if i == \"S\":\n s+=1\n else:\n if s==0:\n ans +=1\n else:\n s-=1\nprint(ans+s)", "x = input()", "x", "input()", "input", "s=0", "s", "0", "ans=0", "ans", "0", "for i in x:\n if i == \"S\":\n s+=1\n else:\n if s==0:\n ans +=1\n else:\n s-=1", "i", "x", "if i == \"S\":\n s+=1\n else:\n if s==0:\n ans +=1\n else:\n s-=1", "i == \"S\"", "i", "\"S\"", "s+=1", "s", "1", "if s==0:\n ans +=1\n else:\n s-=1", "s==0", "s", "0", "ans +=1", "ans", "1", "s-=1", "s", "1", "print(ans+s)", "print", "ans+s", "ans", "s", "x = input()", "input()", "x", "s=0", "0", "s", "ans +=1", "1", "ans", "s-=1", "1", "s", "ans=0", "0", "ans", "s+=1", "1", "s" ]
x = input() s=0 ans=0 for i in x: if i == "S": s+=1 else: if s==0: ans +=1 else: s-=1 print(ans+s)
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 17, 4, 18, 13, 13, 2, 17, 17, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 2, 13, 10, 18, 13, 10, 4, 13 ]
[ [ 79, 4 ], [ 76, 11 ], [ 82, 18 ], [ 33, 32 ], [ 37, 36 ], [ 32, 39 ], [ 42, 41 ], [ 45, 44 ], [ 32, 44 ], [ 44, 48 ], [ 52, 51 ], [ 41, 55 ], [ 58, 55 ], [ 51, 55 ], [ 59, 58 ], [ 62, 61 ], [ 61, 65 ], [ 36, 65 ], [ 74, 71 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ] ]
[ "import sys\n\nreadline = sys.stdin.readline\nMOD = 10 ** 9 + 7\nINF = float('INF')\nsys.setrecursionlimit(10 ** 5)\n\n\ndef main():\n s = input()\n ans = len(s)\n cnt = 0\n\n for char in s:\n if char == \"S\":\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 2\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "readline = sys.stdin.readline", "readline", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "MOD = 10 ** 9 + 7", "MOD", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "INF = float('INF')", "INF", "float('INF')", "float", "'INF'", "sys.setrecursionlimit(10 ** 5)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 5", "10", "5", "def main():\n s = input()\n ans = len(s)\n cnt = 0\n\n for char in s:\n if char == \"S\":\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 2\n\n print(ans)", "main", "s = input()", "s", "input()", "input", "ans = len(s)", "ans", "len(s)", "len", "s", "cnt = 0", "cnt", "0", "for char in s:\n if char == \"S\":\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 2\n\n ", "char", "s", "if char == \"S\":\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 2\n\n ", "char == \"S\"", "char", "\"S\"", "cnt += 1", "cnt", "1", "if cnt > 0:\n cnt -= 1\n ans -= 2\n\n ", "cnt > 0", "cnt", "0", "cnt -= 1", "cnt", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n s = input()\n ans = len(s)\n cnt = 0\n\n for char in s:\n if char == \"S\":\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 2\n\n print(ans)", "def main():\n s = input()\n ans = len(s)\n cnt = 0\n\n for char in s:\n if char == \"S\":\n cnt += 1\n else:\n if cnt > 0:\n cnt -= 1\n ans -= 2\n\n print(ans)", "main", "MOD = 10 ** 9 + 7", "10 ** 9 + 7", "MOD", "readline = sys.stdin.readline", "sys.stdin.readline", "readline", "INF = float('INF')", "float('INF')", "INF" ]
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): s = input() ans = len(s) cnt = 0 for char in s: if char == "S": cnt += 1 else: if cnt > 0: cnt -= 1 ans -= 2 print(ans) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 40, 2 ], [ 52, 6 ], [ 41, 9 ], [ 43, 11 ], [ 15, 14 ], [ 41, 14 ], [ 14, 18 ], [ 37, 21 ], [ 44, 25 ], [ 50, 25 ], [ 38, 25 ], [ 46, 28 ], [ 49, 31 ], [ 47, 35 ], [ 53, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "X = input()\n \nval = len(X)\nsum = 0\nfor i in X:\n if i == \"S\":\n sum += 1\n else:\n if sum > 0:\n val -= 2\n sum -= 1\n \nprint(val)", "X = input()", "X", "input()", "input", "val = len(X)", "val", "len(X)", "len", "X", "sum = 0", "sum", "0", "for i in X:\n if i == \"S\":\n sum += 1\n else:\n if sum > 0:\n val -= 2\n sum -= 1\n ", "i", "X", "if i == \"S\":\n sum += 1\n else:\n if sum > 0:\n val -= 2\n sum -= 1\n ", "i == \"S\"", "i", "\"S\"", "sum += 1", "sum", "1", "if sum > 0:\n val -= 2\n sum -= 1\n ", "sum > 0", "sum", "0", "val -= 2", "val", "2", "sum -= 1", "sum", "1", "print(val)", "print", "val", "sum += 1", "1", "sum", "X = input()", "input()", "X", "sum = 0", "0", "sum", "val -= 2", "2", "val", "sum -= 1", "1", "sum", "val = len(X)", "len(X)", "val" ]
X = input() val = len(X) sum = 0 for i in X: if i == "S": sum += 1 else: if sum > 0: val -= 2 sum -= 1 print(val)
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 42, 2, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 2, 18, 13, 13, 17, 40, 13, 17, 42, 2, 2, 13, 4, 13, 13, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 2, 4, 13, 13, 13, 17, 0, 13, 4, 13, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 14, 2, 13, 17, 4, 13, 10, 4, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 168, 11 ], [ 171, 16 ], [ 26, 25 ], [ 30, 29 ], [ 33, 32 ], [ 36, 35 ], [ 39, 38 ], [ 38, 42 ], [ 104, 42 ], [ 84, 42 ], [ 56, 42 ], [ 25, 45 ], [ 25, 49 ], [ 38, 50 ], [ 104, 50 ], [ 84, 50 ], [ 56, 50 ], [ 54, 53 ], [ 57, 56 ], [ 25, 62 ], [ 38, 63 ], [ 104, 63 ], [ 84, 63 ], [ 56, 63 ], [ 29, 66 ], [ 95, 66 ], [ 53, 66 ], [ 38, 71 ], [ 84, 71 ], [ 104, 71 ], [ 56, 71 ], [ 25, 74 ], [ 25, 77 ], [ 38, 78 ], [ 84, 78 ], [ 104, 78 ], [ 56, 78 ], [ 82, 81 ], [ 85, 84 ], [ 88, 87 ], [ 53, 91 ], [ 29, 91 ], [ 95, 91 ], [ 81, 92 ], [ 32, 92 ], [ 101, 92 ], [ 96, 95 ], [ 53, 98 ], [ 29, 98 ], [ 95, 98 ], [ 81, 99 ], [ 32, 99 ], [ 101, 99 ], [ 102, 101 ], [ 105, 104 ], [ 25, 111 ], [ 87, 112 ], [ 35, 112 ], [ 117, 116 ], [ 121, 120 ], [ 116, 123 ], [ 126, 125 ], [ 129, 128 ], [ 132, 131 ], [ 120, 134 ], [ 116, 138 ], [ 131, 139 ], [ 143, 142 ], [ 125, 146 ], [ 149, 146 ], [ 142, 146 ], [ 150, 149 ], [ 153, 152 ], [ 120, 157 ], [ 152, 159 ], [ 128, 159 ], [ 178, 166 ], [ 168, 169 ], [ 171, 172 ] ]
[ "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve1():\n x = input()\n\n cnt_S = 0\n cnt_T = 0\n res = 0\n i = 0\n while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n print(len(x) - res)\n\n\ndef resolve2():\n x = input()\n n = len(x)\n\n stack = 0\n res = 0\n for i in range(n):\n if x[i] == \"S\":\n stack += 1\n elif stack > 0:\n stack -= 1\n res += 1\n\n print(n - res * 2)\n\n\nif __name__ == '__main__':\n resolve2()", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "f_inf = float('inf')", "f_inf", "float('inf')", "float", "'inf'", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "def resolve1():\n x = input()\n\n cnt_S = 0\n cnt_T = 0\n res = 0\n i = 0\n while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n print(len(x) - res)", "resolve1", "x = input()", "x", "input()", "input", "cnt_S = 0", "cnt_S", "0", "cnt_T = 0", "cnt_T", "0", "res = 0", "res", "0", "i = 0", "i", "0", "while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n ", "i < len(x)", "i", "len(x)", "len", "x", "if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n ", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "cnt_S += 1", "cnt_S", "1", "i += 1", "i", "1", "elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n ", "x[i] == \"T\" and cnt_S != 0", "x[i] == \"T\"", "x[i]", "x", "i", "\"T\"", "cnt_S != 0", "cnt_S", "0", "while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n ", "i < len(x) and x[i] == \"T\"", "i < len(x)", "i", "len(x)", "len", "x", "x[i] == \"T\"", "x[i]", "x", "i", "\"T\"", "cnt_T += 1", "cnt_T", "1", "i += 1", "i", "1", "res += min(cnt_S, cnt_T) * 2", "res", "min(cnt_S, cnt_T) * 2", "min(cnt_S, cnt_T)", "min", "cnt_S", "cnt_T", "2", "cnt_S -= min(cnt_S, cnt_T)", "cnt_S", "min(cnt_S, cnt_T)", "min", "cnt_S", "cnt_T", "cnt_T = 0", "cnt_T", "0", "i += 1", "i", "1", "print(len(x) - res)", "print", "len(x) - res", "len(x)", "len", "x", "res", "def resolve2():\n x = input()\n n = len(x)\n\n stack = 0\n res = 0\n for i in range(n):\n if x[i] == \"S\":\n stack += 1\n elif stack > 0:\n stack -= 1\n res += 1\n\n print(n - res * 2)", "resolve2", "x = input()", "x", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "stack = 0", "stack", "0", "res = 0", "res", "0", "for i in range(n):\n if x[i] == \"S\":\n stack += 1\n elif stack > 0:\n stack -= 1\n res += 1\n\n ", "i", "range(n)", "range", "n", "if x[i] == \"S\":\n stack += 1\n elif stack > 0:\n stack -= 1\n res += 1\n\n ", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "stack += 1", "stack", "1", "elif stack > 0:\n stack -= 1\n res += 1\n\n ", "stack > 0", "stack", "0", "stack -= 1", "stack", "1", "res += 1", "res", "1", "print(n - res * 2)", "print", "n - res * 2", "n", "res * 2", "res", "2", "if __name__ == '__main__':\n resolve2()", "__name__ == '__main__'", "__name__", "'__main__'", "resolve2()", "resolve2", "f_inf = float('inf')", "float('inf')", "f_inf", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "def resolve1():\n x = input()\n\n cnt_S = 0\n cnt_T = 0\n res = 0\n i = 0\n while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n print(len(x) - res)", "def resolve1():\n x = input()\n\n cnt_S = 0\n cnt_T = 0\n res = 0\n i = 0\n while i < len(x):\n if x[i] == \"S\":\n cnt_S += 1\n i += 1\n\n elif x[i] == \"T\" and cnt_S != 0:\n while i < len(x) and x[i] == \"T\":\n cnt_T += 1\n i += 1\n res += min(cnt_S, cnt_T) * 2\n cnt_S -= min(cnt_S, cnt_T)\n cnt_T = 0\n else:\n i += 1\n\n print(len(x) - res)", "resolve1", "def resolve2():\n x = input()\n n = len(x)\n\n stack = 0\n res = 0\n for i in range(n):\n if x[i] == \"S\":\n stack += 1\n elif stack > 0:\n stack -= 1\n res += 1\n\n print(n - res * 2)", "def resolve2():\n x = input()\n n = len(x)\n\n stack = 0\n res = 0\n for i in range(n):\n if x[i] == \"S\":\n stack += 1\n elif stack > 0:\n stack -= 1\n res += 1\n\n print(n - res * 2)", "resolve2" ]
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve1(): x = input() cnt_S = 0 cnt_T = 0 res = 0 i = 0 while i < len(x): if x[i] == "S": cnt_S += 1 i += 1 elif x[i] == "T" and cnt_S != 0: while i < len(x) and x[i] == "T": cnt_T += 1 i += 1 res += min(cnt_S, cnt_T) * 2 cnt_S -= min(cnt_S, cnt_T) cnt_T = 0 else: i += 1 print(len(x) - res) def resolve2(): x = input() n = len(x) stack = 0 res = 0 for i in range(n): if x[i] == "S": stack += 1 elif stack > 0: stack -= 1 res += 1 print(n - res * 2) if __name__ == '__main__': resolve2()
[ 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, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 50, 2 ], [ 53, 6 ], [ 56, 9 ], [ 13, 12 ], [ 51, 12 ], [ 12, 16 ], [ 41, 19 ], [ 57, 23 ], [ 48, 23 ], [ 42, 23 ], [ 44, 26 ], [ 47, 29 ], [ 51, 36 ], [ 45, 39 ], [ 54, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "X = input()\n\nres = 0\nl = 0\nfor x in X:\n if x == 'S':\n l += 1\n elif l > 0:\n res += 1\n l -= 1\nprint(len(X)-2*res)", "X = input()", "X", "input()", "input", "res = 0", "res", "0", "l = 0", "l", "0", "for x in X:\n if x == 'S':\n l += 1\n elif l > 0:\n res += 1\n l -= 1", "x", "X", "if x == 'S':\n l += 1\n elif l > 0:\n res += 1\n l -= 1", "x == 'S'", "x", "'S'", "l += 1", "l", "1", "elif l > 0:\n res += 1\n l -= 1", "l > 0", "l", "0", "res += 1", "res", "1", "l -= 1", "l", "1", "print(len(X)-2*res)", "print", "len(X)-2*res", "len(X)", "len", "X", "2*res", "2", "res", "l += 1", "1", "l", "res += 1", "1", "res", "l -= 1", "1", "l", "X = input()", "input()", "X", "res = 0", "0", "res", "l = 0", "0", "l" ]
X = input() res = 0 l = 0 for x in X: if x == 'S': l += 1 elif l > 0: res += 1 l -= 1 print(len(X)-2*res)
[ 7, 0, 13, 4, 18, 4, 13, 13, 17, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 58, 2 ], [ 49, 11 ], [ 52, 14 ], [ 18, 17 ], [ 59, 22 ], [ 59, 26 ], [ 17, 27 ], [ 50, 31 ], [ 56, 31 ], [ 55, 34 ], [ 61, 37 ], [ 59, 44 ], [ 62, 46 ], [ 53, 46 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "x = input().replace(\"ST\", \"\")\ns = 0\ncnt = 0\nfor i in range(len(x)):\n if x[i] == \"S\": s += 1\n else:\n if s > 0: \n s -= 1\n cnt += 1\nprint(len(x)-cnt*2)", "x = input().replace(\"ST\", \"\")", "x", "input().replace(\"ST\", \"\")", "().replace", "()", "input", "replace", "\"ST\"", "\"\"", "s = 0", "s", "0", "cnt = 0", "cnt", "0", "for i in range(len(x)):\n if x[i] == \"S\": s += 1\n else:\n if s > 0: \n s -= 1\n cnt += 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == \"S\": s += 1\n else:\n if s > 0: \n s -= 1\n cnt += 1", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "if s > 0: \n s -= 1\n cnt += 1", "s > 0", "s", "0", "s -= 1", "s", "1", "cnt += 1", "cnt", "1", "print(len(x)-cnt*2)", "print", "len(x)-cnt*2", "len(x)", "len", "x", "cnt*2", "cnt", "2", "s = 0", "0", "s", "cnt = 0", "0", "cnt", "s -= 1", "1", "s", "x = input().replace(\"ST\", \"\")", "input().replace(\"ST\", \"\")", "x", "cnt += 1", "1", "cnt" ]
x = input().replace("ST", "") s = 0 cnt = 0 for i in range(len(x)): if x[i] == "S": s += 1 else: if s > 0: s -= 1 cnt += 1 print(len(x)-cnt*2)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 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, 14, 2, 2, 13, 17, 2, 18, 13, 17, 17, 0, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 62, 3 ], [ 68, 7 ], [ 12, 11 ], [ 63, 11 ], [ 11, 15 ], [ 69, 19 ], [ 11, 25 ], [ 69, 29 ], [ 69, 32 ], [ 69, 37 ], [ 11, 43 ], [ 69, 47 ], [ 65, 51 ], [ 69, 54 ], [ 69, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "from collections import deque\nX = input()\nque = deque()\nfor x in X:\n if x=='S':\n que.append('S')\n elif x=='T' and (not que or que[-1]=='T'):\n que.append('T')\n elif x=='T' and que[-1]=='S':\n _ = que.pop()\nprint(len(que))", "from collections import deque", "X = input()", "X", "input()", "input", "que = deque()", "que", "deque()", "deque", "for x in X:\n if x=='S':\n que.append('S')\n elif x=='T' and (not que or que[-1]=='T'):\n que.append('T')\n elif x=='T' and que[-1]=='S':\n _ = que.pop()", "x", "X", "if x=='S':\n que.append('S')\n elif x=='T' and (not que or que[-1]=='T'):\n que.append('T')\n elif x=='T' and que[-1]=='S':\n _ = que.pop()", "x=='S'", "x", "'S'", "que.append('S')", "que.append", "que", "append", "'S'", "elif x=='T' and (not que or que[-1]=='T'):\n que.append('T')\n ", "x=='T' and (not que or que[-1]=='T')", "x=='T'", "x", "'T'", "not que or que[-1]=='T'", "not que", "que", "que[-1]=='T'", "que[-1]", "que", "-1", "'T'", "que.append('T')", "que.append", "que", "append", "'T'", "elif x=='T' and que[-1]=='S':\n _ = que.pop()", "x=='T' and que[-1]=='S'", "x=='T'", "x", "'T'", "que[-1]=='S'", "que[-1]", "que", "-1", "'S'", "_ = que.pop()", "_", "que.pop()", "que.pop", "que", "pop", "print(len(que))", "print", "len(que)", "len", "que", "X = input()", "input()", "X", "_ = que.pop()", "que.pop()", "_", "que = deque()", "deque()", "que" ]
from collections import deque X = input() que = deque() for x in X: if x=='S': que.append('S') elif x=='T' and (not que or que[-1]=='T'): que.append('T') elif x=='T' and que[-1]=='S': _ = que.pop() print(len(que))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 63, 2 ], [ 54, 8 ], [ 66, 11 ], [ 60, 14 ], [ 18, 17 ], [ 64, 22 ], [ 64, 26 ], [ 17, 27 ], [ 48, 30 ], [ 55, 34 ], [ 52, 34 ], [ 49, 34 ], [ 57, 37 ], [ 51, 40 ], [ 58, 45 ], [ 61, 45 ], [ 52, 46 ], [ 49, 46 ], [ 55, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "x=list(input())\ns=0\nt=0\nans=0\nfor i in range(len(x)):\n if x[i]==\"S\":\n s+=1\n\n else:\n if s==0:\n ans+=1\n else:\n s-=1\n\nprint(ans+s)", "x=list(input())", "x", "list(input())", "list", "input()", "input", "s=0", "s", "0", "t=0", "t", "0", "ans=0", "ans", "0", "for i in range(len(x)):\n if x[i]==\"S\":\n s+=1\n\n else:\n if s==0:\n ans+=1\n else:\n s-=1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i]==\"S\":\n s+=1\n\n else:\n if s==0:\n ans+=1\n else:\n s-=1", "x[i]==\"S\"", "x[i]", "x", "i", "\"S\"", "s+=1", "s", "1", "if s==0:\n ans+=1\n else:\n s-=1", "s==0", "s", "0", "ans+=1", "ans", "1", "s-=1", "s", "1", "print(ans+s)", "print", "ans+s", "ans", "s", "s+=1", "1", "s", "s-=1", "1", "s", "s=0", "0", "s", "ans+=1", "1", "ans", "ans=0", "0", "ans", "x=list(input())", "list(input())", "x", "t=0", "0", "t" ]
x=list(input()) s=0 t=0 ans=0 for i in range(len(x)): if x[i]=="S": s+=1 else: if s==0: ans+=1 else: s-=1 print(ans+s)
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 17, 14, 2, 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, 17, 0, 13, 4, 13, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 69, 2 ], [ 66, 6 ], [ 10, 9 ], [ 70, 14 ], [ 70, 18 ], [ 9, 19 ], [ 67, 23 ], [ 70, 29 ], [ 9, 30 ], [ 67, 37 ], [ 67, 41 ], [ 67, 46 ], [ 67, 51 ], [ 63, 55 ], [ 67, 58 ], [ 64, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ] ]
[ "X = input()\nl = []\nfor i in range(len(X)):\n if X[i] == \"S\":\n l.append(\"S\")\n elif X[i] == \"T\":\n if len(l) > 0 and l[-1] == \"S\":\n l.pop(-1)\n # lが空 or lの末尾がT\n else:\n l.append(\"T\")\nans = len(l)\nprint(ans)", "X = input()", "X", "input()", "input", "l = []", "l", "[]", "for i in range(len(X)):\n if X[i] == \"S\":\n l.append(\"S\")\n elif X[i] == \"T\":\n if len(l) > 0 and l[-1] == \"S\":\n l.pop(-1)\n # lが空 or lの末尾がT\n else:\n l.append(\"T\")", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == \"S\":\n l.append(\"S\")\n elif X[i] == \"T\":\n if len(l) > 0 and l[-1] == \"S\":\n l.pop(-1)\n # lが空 or lの末尾がT\n else:\n l.append(\"T\")", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "l.append(\"S\")", "l.append", "l", "append", "\"S\"", "elif X[i] == \"T\":\n if len(l) > 0 and l[-1] == \"S\":\n l.pop(-1)\n # lが空 or lの末尾がT\n else:\n l.append(\"T\")", "X[i] == \"T\"", "X[i]", "X", "i", "\"T\"", "if len(l) > 0 and l[-1] == \"S\":\n l.pop(-1)\n # lが空 or lの末尾がT\n else:\n l.append(\"T\")", "len(l) > 0 and l[-1] == \"S\"", "len(l) > 0", "len(l)", "len", "l", "0", "l[-1] == \"S\"", "l[-1]", "l", "-1", "\"S\"", "l.pop(-1)", "l.pop", "l", "pop", "-1", "l.append(\"T\")", "l.append", "l", "append", "\"T\"", "ans = len(l)", "ans", "len(l)", "len", "l", "print(ans)", "print", "ans", "ans = len(l)", "len(l)", "ans", "l = []", "[]", "l", "X = input()", "input()", "X" ]
X = input() l = [] for i in range(len(X)): if X[i] == "S": l.append("S") elif X[i] == "T": if len(l) > 0 and l[-1] == "S": l.pop(-1) # lが空 or lの末尾がT else: l.append("T") ans = len(l) print(ans)
[ 7, 0, 13, 18, 4, 13, 4, 13, 39, 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, 2, 13, 13, 10, 17, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 45, 2 ], [ 57, 11 ], [ 48, 14 ], [ 18, 17 ], [ 46, 17 ], [ 17, 21 ], [ 49, 25 ], [ 43, 25 ], [ 55, 25 ], [ 54, 28 ], [ 51, 31 ], [ 42, 34 ], [ 43, 39 ], [ 55, 39 ], [ 49, 39 ], [ 52, 40 ], [ 58, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "s=list(input())[::-1]\n\ns_cnt=0\nt_cnt=0\n\n\nfor ss in s:\n if ss==\"S\":\n if t_cnt>0:\n t_cnt-=1\n else:\n s_cnt+=1\n else:\n t_cnt+=1\nprint(t_cnt+s_cnt)\n", "s=list(input())[::-1]", "s", "list(input())[::-1]", "(input())", "list", "input()", "input", "::-1", "-1", "s_cnt=0", "s_cnt", "0", "t_cnt=0", "t_cnt", "0", "for ss in s:\n if ss==\"S\":\n if t_cnt>0:\n t_cnt-=1\n else:\n s_cnt+=1\n else:\n t_cnt+=1", "ss", "s", "if ss==\"S\":\n if t_cnt>0:\n t_cnt-=1\n else:\n s_cnt+=1\n else:\n t_cnt+=1", "ss==\"S\"", "ss", "\"S\"", "if t_cnt>0:\n t_cnt-=1\n else:\n s_cnt+=1\n ", "t_cnt>0", "t_cnt", "0", "t_cnt-=1", "t_cnt", "1", "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", "t_cnt+=1", "1", "t_cnt", "s=list(input())[::-1]", "list(input())[::-1]", "s", "t_cnt=0", "0", "t_cnt", "s_cnt+=1", "1", "s_cnt", "t_cnt-=1", "1", "t_cnt", "s_cnt=0", "0", "s_cnt" ]
s=list(input())[::-1] s_cnt=0 t_cnt=0 for ss in s: if ss=="S": if t_cnt>0: t_cnt-=1 else: s_cnt+=1 else: t_cnt+=1 print(t_cnt+s_cnt)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 13, 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, 10, 4, 13 ]
[ [ 38, 2 ], [ 44, 6 ], [ 39, 9 ], [ 56, 10 ], [ 39, 13 ], [ 50, 14 ], [ 18, 17 ], [ 39, 17 ], [ 17, 21 ], [ 53, 24 ], [ 41, 29 ], [ 47, 32 ], [ 48, 36 ], [ 57, 36 ], [ 38, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "s=input()\nn,ans,l=len(s),len(s),0\nfor c in s:\n\tif c=='S':\n\t\tl += 1\n\telif l:\n\t\tl -= 1\n\t\tans -= 2\nprint(ans)", "s=input()", "s", "input()", "input", "n,ans,l=len(s),len(s),0", "n", "len(s)", "len", "s", "ans", "len(s)", "len", "s", "l", "0", "for c in s:\n\tif c=='S':\n\t\tl += 1\n\telif l:\n\t\tl -= 1\n\t\tans -= 2", "c", "s", "if c=='S':\n\t\tl += 1\n\telif l:\n\t\tl -= 1\n\t\tans -= 2", "c=='S'", "c", "'S'", "l += 1", "l", "1", "elif l:\n\t\tl -= 1\n\t\tans -= 2", "l", "l -= 1", "l", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "s=input()", "input()", "s", "l -= 1", "1", "l", "n,ans,l=len(s),len(s),0", "len(s)", "n", "ans -= 2", "2", "ans", "l=len(s),len(s),0", "0", "l", "l += 1", "1", "l", "ans,l=len(s),len(s),0", "len(s)", "ans" ]
s=input() n,ans,l=len(s),len(s),0 for c in s: if c=='S': l += 1 elif l: l -= 1 ans -= 2 print(ans)
[ 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, 40, 4, 13, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 18, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 66, 2 ], [ 63, 6 ], [ 67, 9 ], [ 60, 11 ], [ 15, 14 ], [ 64, 17 ], [ 67, 21 ], [ 14, 22 ], [ 61, 26 ], [ 67, 29 ], [ 14, 30 ], [ 61, 36 ], [ 61, 40 ], [ 61, 45 ], [ 61, 49 ], [ 67, 52 ], [ 14, 53 ], [ 61, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "x = input()\n#tのラストとsの最初を知りたい\nn = len(x)\na = []\nfor i in range(n):\n if x[i]==\"S\":\n a.append(x[i])\n else:\n if len(a)!=0 and a[-1]=='S' :\n a.pop()\n else:\n a.append(x[i])\nprint(len(a))", "x = input()", "x", "input()", "input", "n = len(x)", "n", "len(x)", "len", "x", "a = []", "a", "[]", "for i in range(n):\n if x[i]==\"S\":\n a.append(x[i])\n else:\n if len(a)!=0 and a[-1]=='S' :\n a.pop()\n else:\n a.append(x[i])", "i", "range(n)", "range", "n", "if x[i]==\"S\":\n a.append(x[i])\n else:\n if len(a)!=0 and a[-1]=='S' :\n a.pop()\n else:\n a.append(x[i])", "x[i]==\"S\"", "x[i]", "x", "i", "\"S\"", "a.append(x[i])", "a.append", "a", "append", "x[i]", "x", "i", "if len(a)!=0 and a[-1]=='S' :\n a.pop()\n else:\n a.append(x[i])", "len(a)!=0 and a[-1]=='S'", "len(a)!=0", "len(a)", "len", "a", "0", "a[-1]=='S'", "a[-1]", "a", "-1", "'S'", "a.pop()", "a.pop", "a", "pop", "a.append(x[i])", "a.append", "a", "append", "x[i]", "x", "i", "print(len(a))", "print", "len(a)", "len", "a", "a = []", "[]", "a", "n = len(x)", "len(x)", "n", "x = input()", "input()", "x" ]
x = input() #tのラストとsの最初を知りたい n = len(x) a = [] for i in range(n): if x[i]=="S": a.append(x[i]) else: if len(a)!=0 and a[-1]=='S' : a.pop() else: a.append(x[i]) print(len(a))
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 17, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 11, 10 ], [ 14, 13 ], [ 4, 13 ], [ 13, 17 ], [ 21, 20 ], [ 26, 25 ], [ 29, 28 ], [ 25, 33 ], [ 20, 33 ], [ 8, 33 ], [ 28, 34 ], [ 10, 34 ], [ 43, 40 ] ]
[ "def main():\n x = input()\n s, t = 0, 0\n for i in x:\n if i == \"S\":\n s += 1\n else:\n if s:\n s -= 1\n else:\n t += 1\n print(s + t)\n\nif __name__ == \"__main__\":\n main()", "def main():\n x = input()\n s, t = 0, 0\n for i in x:\n if i == \"S\":\n s += 1\n else:\n if s:\n s -= 1\n else:\n t += 1\n print(s + t)", "main", "x = input()", "x", "input()", "input", "s, t = 0, 0", "s", "0", "t", "0", "for i in x:\n if i == \"S\":\n s += 1\n else:\n if s:\n s -= 1\n else:\n t += 1\n ", "i", "x", "if i == \"S\":\n s += 1\n else:\n if s:\n s -= 1\n else:\n t += 1\n ", "i == \"S\"", "i", "\"S\"", "s += 1", "s", "1", "if s:\n s -= 1\n else:\n t += 1\n ", "s", "s -= 1", "s", "1", "t += 1", "t", "1", "print(s + t)", "print", "s + t", "s", "t", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n x = input()\n s, t = 0, 0\n for i in x:\n if i == \"S\":\n s += 1\n else:\n if s:\n s -= 1\n else:\n t += 1\n print(s + t)", "def main():\n x = input()\n s, t = 0, 0\n for i in x:\n if i == \"S\":\n s += 1\n else:\n if s:\n s -= 1\n else:\n t += 1\n print(s + t)", "main" ]
def main(): x = input() s, t = 0, 0 for i in x: if i == "S": s += 1 else: if s: s -= 1 else: t += 1 print(s + t) if __name__ == "__main__": main()
[ 7, 15, 13, 15, 0, 13, 18, 18, 18, 13, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 0, 13, 4, 18, 4, 18, 4, 13, 13, 17, 13, 0, 13, 4, 13, 13, 0, 13, 18, 13, 17, 0, 13, 17, 0, 13, 39, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 13, 0, 13, 17, 4, 18, 13, 13, 39, 13, 13, 0, 13, 18, 13, 13, 0, 13, 17, 14, 2, 13, 2, 13, 17, 4, 18, 13, 13, 39, 13, 13, 0, 13, 4, 13, 13, 14, 2, 18, 18, 13, 17, 17, 17, 4, 18, 13, 13, 14, 2, 18, 18, 13, 17, 17, 17, 4, 18, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 42, 13, 0, 13, 18, 4, 18, 13, 13, 17, 0, 13, 18, 4, 18, 13, 13, 17, 14, 40, 13, 13, 0, 13, 2, 13, 17, 0, 13, 13, 0, 13, 2, 13, 17, 0, 13, 17, 0, 13, 2, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 2, 13, 10, 4, 13, 10, 18, 13, 10, 12, 13 ]
[ [ 200, 5 ], [ 197, 21 ], [ 194, 26 ], [ 36, 35 ], [ 201, 41 ], [ 47, 46 ], [ 35, 49 ], [ 52, 51 ], [ 35, 53 ], [ 57, 56 ], [ 60, 59 ], [ 63, 62 ], [ 46, 65 ], [ 35, 69 ], [ 62, 70 ], [ 51, 71 ], [ 83, 71 ], [ 74, 73 ], [ 59, 77 ], [ 84, 83 ], [ 35, 85 ], [ 62, 86 ], [ 89, 88 ], [ 62, 92 ], [ 46, 94 ], [ 59, 98 ], [ 105, 104 ], [ 59, 107 ], [ 104, 112 ], [ 104, 118 ], [ 104, 124 ], [ 104, 130 ], [ 134, 133 ], [ 137, 136 ], [ 140, 139 ], [ 145, 144 ], [ 104, 148 ], [ 153, 152 ], [ 104, 156 ], [ 144, 161 ], [ 133, 161 ], [ 177, 161 ], [ 169, 161 ], [ 152, 162 ], [ 136, 162 ], [ 165, 164 ], [ 152, 166 ], [ 136, 166 ], [ 170, 169 ], [ 152, 170 ], [ 136, 170 ], [ 173, 172 ], [ 144, 174 ], [ 133, 174 ], [ 177, 174 ], [ 169, 174 ], [ 178, 177 ], [ 181, 180 ], [ 46, 182 ], [ 172, 183 ], [ 164, 183 ], [ 139, 183 ], [ 88, 183 ], [ 73, 183 ], [ 56, 183 ], [ 180, 186 ], [ 204, 192 ], [ 194, 195 ], [ 197, 198 ], [ 200, 201 ] ]
[ "import sys\nfrom collections import deque\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n X = readline().decode('utf-8').strip()\n L = len(X)\n S = X[0]\n count = 0\n RLE = []\n for i in range(L):\n if X[i] == S:\n count += 1\n else:\n RLE.append((S,count))\n S = X[i]\n count = 1\n if i==L-1:\n RLE.append((S,count))\n d = deque(RLE)\n if d[0][0] == 'T':\n d.popleft()\n if d[-1][0] == 'S':\n d.pop()\n s = 0\n t = 0\n count = 0\n while d:\n s += d.popleft()[1]\n t = d.popleft()[1]\n if s>=t:\n count += t*2\n s -= t\n else:\n count += s*2\n s = 0\n ans = L-count\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "from collections import deque", "readline = sys.stdin.buffer.readline", "readline", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "sys.setrecursionlimit(10 ** 8)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 8", "10", "8", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "MOD = 10 ** 9 + 7", "MOD", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "def main():\n X = readline().decode('utf-8').strip()\n L = len(X)\n S = X[0]\n count = 0\n RLE = []\n for i in range(L):\n if X[i] == S:\n count += 1\n else:\n RLE.append((S,count))\n S = X[i]\n count = 1\n if i==L-1:\n RLE.append((S,count))\n d = deque(RLE)\n if d[0][0] == 'T':\n d.popleft()\n if d[-1][0] == 'S':\n d.pop()\n s = 0\n t = 0\n count = 0\n while d:\n s += d.popleft()[1]\n t = d.popleft()[1]\n if s>=t:\n count += t*2\n s -= t\n else:\n count += s*2\n s = 0\n ans = L-count\n print(ans)", "main", "X = readline().decode('utf-8').strip()", "X", "readline().decode('utf-8').strip()", "().decode('utf-8').strip", "().decode('utf-8')", "().decode", "()", "readline", "decode", "'utf-8'", "strip", "L = len(X)", "L", "len(X)", "len", "X", "S = X[0]", "S", "X[0]", "X", "0", "count = 0", "count", "0", "RLE = []", "RLE", "[]", "for i in range(L):\n if X[i] == S:\n count += 1\n else:\n RLE.append((S,count))\n S = X[i]\n count = 1\n if i==L-1:\n RLE.append((S,count))\n ", "i", "range(L)", "range", "L", "if X[i] == S:\n count += 1\n else:\n RLE.append((S,count))\n S = X[i]\n count = 1\n ", "X[i] == S", "X[i]", "X", "i", "S", "count += 1", "count", "1", "RLE.append((S,count))", "RLE.append", "RLE", "append", "(S,count)", "S", "count", "S = X[i]", "S", "X[i]", "X", "i", "count = 1", "count", "1", "if i==L-1:\n RLE.append((S,count))\n ", "i==L-1", "i", "L-1", "L", "1", "RLE.append((S,count))", "RLE.append", "RLE", "append", "(S,count)", "S", "count", "d = deque(RLE)", "d", "deque(RLE)", "deque", "RLE", "if d[0][0] == 'T':\n d.popleft()\n ", "d[0][0] == 'T'", "d[0][0]", "[0]", "d", "0", "0", "'T'", "d.popleft()", "d.popleft", "d", "popleft", "if d[-1][0] == 'S':\n d.pop()\n ", "d[-1][0] == 'S'", "d[-1][0]", "[-1]", "d", "-1", "0", "'S'", "d.pop()", "d.pop", "d", "pop", "s = 0", "s", "0", "t = 0", "t", "0", "count = 0", "count", "0", "while d:\n s += d.popleft()[1]\n t = d.popleft()[1]\n if s>=t:\n count += t*2\n s -= t\n else:\n count += s*2\n s = 0\n ", "d", "s += d.popleft()[1]", "s", "d.popleft()[1]", "d.popleft()", "d.popleft", "d", "popleft", "1", "t = d.popleft()[1]", "t", "d.popleft()[1]", "d.popleft()", "d.popleft", "d", "popleft", "1", "if s>=t:\n count += t*2\n s -= t\n else:\n count += s*2\n s = 0\n ", "s>=t", "s", "t", "count += t*2", "count", "t*2", "t", "2", "s -= t", "s", "t", "count += s*2", "count", "s*2", "s", "2", "s = 0", "s", "0", "ans = L-count", "ans", "L-count", "L", "count", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "MOD = 10 ** 9 + 7", "10 ** 9 + 7", "MOD", "INF = float('inf')", "float('inf')", "INF", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline", "def main():\n X = readline().decode('utf-8').strip()\n L = len(X)\n S = X[0]\n count = 0\n RLE = []\n for i in range(L):\n if X[i] == S:\n count += 1\n else:\n RLE.append((S,count))\n S = X[i]\n count = 1\n if i==L-1:\n RLE.append((S,count))\n d = deque(RLE)\n if d[0][0] == 'T':\n d.popleft()\n if d[-1][0] == 'S':\n d.pop()\n s = 0\n t = 0\n count = 0\n while d:\n s += d.popleft()[1]\n t = d.popleft()[1]\n if s>=t:\n count += t*2\n s -= t\n else:\n count += s*2\n s = 0\n ans = L-count\n print(ans)", "def main():\n X = readline().decode('utf-8').strip()\n L = len(X)\n S = X[0]\n count = 0\n RLE = []\n for i in range(L):\n if X[i] == S:\n count += 1\n else:\n RLE.append((S,count))\n S = X[i]\n count = 1\n if i==L-1:\n RLE.append((S,count))\n d = deque(RLE)\n if d[0][0] == 'T':\n d.popleft()\n if d[-1][0] == 'S':\n d.pop()\n s = 0\n t = 0\n count = 0\n while d:\n s += d.popleft()[1]\n t = d.popleft()[1]\n if s>=t:\n count += t*2\n s -= t\n else:\n count += s*2\n s = 0\n ans = L-count\n print(ans)", "main" ]
import sys from collections import deque readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): X = readline().decode('utf-8').strip() L = len(X) S = X[0] count = 0 RLE = [] for i in range(L): if X[i] == S: count += 1 else: RLE.append((S,count)) S = X[i] count = 1 if i==L-1: RLE.append((S,count)) d = deque(RLE) if d[0][0] == 'T': d.popleft() if d[-1][0] == 'S': d.pop() s = 0 t = 0 count = 0 while d: s += d.popleft()[1] t = d.popleft()[1] if s>=t: count += t*2 s -= t else: count += s*2 s = 0 ans = L-count print(ans) if __name__ == '__main__': main()
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 12, 11 ], [ 4, 14 ], [ 17, 16 ], [ 4, 16 ], [ 16, 20 ], [ 24, 23 ], [ 8, 27 ], [ 30, 27 ], [ 23, 27 ], [ 31, 30 ], [ 34, 33 ], [ 33, 37 ], [ 11, 37 ], [ 46, 43 ] ]
[ "#!/usr/bin python3\n# -*- coding: utf-8 -*-\n\ndef main():\n S = input()\n cnt = 0\n ret = len(S)\n for a in S:\n if a == 'S':\n cnt += 1\n else:\n if cnt>0:\n cnt-=1\n ret-=2\n print(ret)\n\nif __name__ == '__main__':\n main()", "def main():\n S = input()\n cnt = 0\n ret = len(S)\n for a in S:\n if a == 'S':\n cnt += 1\n else:\n if cnt>0:\n cnt-=1\n ret-=2\n print(ret)", "main", "S = input()", "S", "input()", "input", "cnt = 0", "cnt", "0", "ret = len(S)", "ret", "len(S)", "len", "S", "for a in S:\n if a == 'S':\n cnt += 1\n else:\n if cnt>0:\n cnt-=1\n ret-=2\n ", "a", "S", "if a == 'S':\n cnt += 1\n else:\n if cnt>0:\n cnt-=1\n ret-=2\n ", "a == 'S'", "a", "'S'", "cnt += 1", "cnt", "1", "if cnt>0:\n cnt-=1\n ret-=2\n ", "cnt>0", "cnt", "0", "cnt-=1", "cnt", "1", "ret-=2", "ret", "2", "print(ret)", "print", "ret", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n S = input()\n cnt = 0\n ret = len(S)\n for a in S:\n if a == 'S':\n cnt += 1\n else:\n if cnt>0:\n cnt-=1\n ret-=2\n print(ret)", "def main():\n S = input()\n cnt = 0\n ret = len(S)\n for a in S:\n if a == 'S':\n cnt += 1\n else:\n if cnt>0:\n cnt-=1\n ret-=2\n print(ret)", "main" ]
#!/usr/bin python3 # -*- coding: utf-8 -*- def main(): S = input() cnt = 0 ret = len(S) for a in S: if a == 'S': cnt += 1 else: if cnt>0: cnt-=1 ret-=2 print(ret) if __name__ == '__main__': main()
[ 7, 14, 2, 13, 17, 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, 2, 13, 17, 2, 18, 13, 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, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 59, 6 ], [ 71, 10 ], [ 68, 13 ], [ 60, 16 ], [ 19, 18 ], [ 60, 23 ], [ 60, 27 ], [ 18, 28 ], [ 62, 31 ], [ 72, 36 ], [ 75, 36 ], [ 57, 36 ], [ 63, 36 ], [ 60, 40 ], [ 18, 41 ], [ 65, 44 ], [ 56, 47 ], [ 74, 50 ], [ 66, 54 ], [ 69, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "if __name__ == \"__main__\":\n x = input()\n\n count = 0\n ans = len(x)\n for i in range(len(x)):\n if x[i] == 'S':\n count += 1\n elif count > 0 and x[i] == 'T':\n ans -= 2\n count -= 1\n else:\n count = 0\n\n print(ans)", "if __name__ == \"__main__\":\n x = input()\n\n count = 0\n ans = len(x)\n for i in range(len(x)):\n if x[i] == 'S':\n count += 1\n elif count > 0 and x[i] == 'T':\n ans -= 2\n count -= 1\n else:\n count = 0\n\n print(ans)", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "x = input()", "x", "input()", "input", "count = 0", "count", "0", "ans = len(x)", "ans", "len(x)", "len", "x", "for i in range(len(x)):\n if x[i] == 'S':\n count += 1\n elif count > 0 and x[i] == 'T':\n ans -= 2\n count -= 1\n else:\n count = 0\n\n ", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == 'S':\n count += 1\n elif count > 0 and x[i] == 'T':\n ans -= 2\n count -= 1\n else:\n count = 0\n\n ", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "count += 1", "count", "1", "elif count > 0 and x[i] == 'T':\n ans -= 2\n count -= 1\n ", "count > 0 and x[i] == 'T'", "count > 0", "count", "0", "x[i] == 'T'", "x[i]", "x", "i", "'T'", "ans -= 2", "ans", "2", "count -= 1", "count", "1", "count = 0", "count", "0", "print(ans)", "print", "ans", "count -= 1", "1", "count", "x = input()", "input()", "x", "count += 1", "1", "count", "ans -= 2", "2", "ans", "ans = len(x)", "len(x)", "ans", "count = 0", "0", "count", "count = 0", "0", "count" ]
if __name__ == "__main__": x = input() count = 0 ans = len(x) for i in range(len(x)): if x[i] == 'S': count += 1 elif count > 0 and x[i] == 'T': ans -= 2 count -= 1 else: count = 0 print(ans)
[ 7, 0, 13, 17, 13, 17, 28, 13, 4, 13, 14, 2, 13, 17, 14, 13, 4, 13, 2, 13, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 25, 2 ], [ 22, 4 ], [ 8, 7 ], [ 7, 12 ], [ 26, 19 ], [ 23, 20 ], [ 22, 23 ], [ 25, 26 ] ]
[ "t,s=0,0\nfor x in input():\n if x=='S':s+=1\n elif s:s-=1\n else:t+=1\nprint(t+s)", "t,s=0,0", "t", "0", "s", "0", "for x in input():\n if x=='S':s+=1\n elif s:s-=1\n else:t+=1", "x", "input()", "input", "if x=='S':s+=1\n elif s:s-=1\n else:t+=1", "x=='S'", "x", "'S'", "elif s:s-=1\n ", "s", "print(t+s)", "print", "t+s", "t", "s", "s=0,0", "0", "s", "t,s=0,0", "0", "t" ]
t,s=0,0 for x in input(): if x=='S':s+=1 elif s:s-=1 else:t+=1 print(t+s)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 2, 13, 17, 0, 13, 2, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 4, 13, 13, 2, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 72, 2 ], [ 54, 6 ], [ 73, 9 ], [ 75, 11 ], [ 55, 13 ], [ 69, 16 ], [ 55, 18 ], [ 63, 21 ], [ 25, 24 ], [ 55, 27 ], [ 73, 31 ], [ 24, 32 ], [ 57, 35 ], [ 64, 38 ], [ 58, 38 ], [ 76, 40 ], [ 67, 40 ], [ 70, 41 ], [ 61, 41 ], [ 66, 43 ], [ 60, 46 ], [ 58, 51 ], [ 64, 51 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "s=input() ; n=len(s)\nss=n//2; tt=n//2\nans=0\nfor i in range(n):\n if s[i]==\"S\":\n ans=max(ans, ss-tt)\n ss-=1\n else:\n tt-=1\nprint(ans*2)", "s=input()", "s", "input()", "input", "n=len(s)", "n", "len(s)", "len", "s", "ss=n//2", "ss", "n//2", "n", "2", "tt=n//2", "tt", "n//2", "n", "2", "ans=0", "ans", "0", "for i in range(n):\n if s[i]==\"S\":\n ans=max(ans, ss-tt)\n ss-=1\n else:\n tt-=1", "i", "range(n)", "range", "n", "if s[i]==\"S\":\n ans=max(ans, ss-tt)\n ss-=1\n else:\n tt-=1", "s[i]==\"S\"", "s[i]", "s", "i", "\"S\"", "ans=max(ans, ss-tt)", "ans", "max(ans, ss-tt)", "max", "ans", "ss-tt", "ss", "tt", "ss-=1", "ss", "1", "tt-=1", "tt", "1", "print(ans*2)", "print", "ans*2", "ans", "2", "n=len(s)", "len(s)", "n", "ans=max(ans, ss-tt)", "max(ans, ss-tt)", "ans", "tt-=1", "1", "tt", "ans=0", "0", "ans", "ss-=1", "1", "ss", "tt=n//2", "n//2", "tt", "s=input()", "input()", "s", "ss=n//2", "n//2", "ss" ]
s=input() ; n=len(s) ss=n//2; tt=n//2 ans=0 for i in range(n): if s[i]=="S": ans=max(ans, ss-tt) ss-=1 else: tt-=1 print(ans*2)
[ 7, 0, 13, 4, 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, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 49, 2 ], [ 52, 8 ], [ 12, 11 ], [ 50, 11 ], [ 11, 15 ], [ 53, 19 ], [ 11, 21 ], [ 53, 27 ], [ 53, 31 ], [ 53, 36 ], [ 53, 40 ], [ 11, 42 ], [ 53, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "X = list(input())\n\nst = []\nfor x in X:\n if x == 'S':\n st.append(x)\n else:\n if len(st) > 0 and st[-1] == 'S':\n st.pop()\n else:\n st.append(x)\nprint(len(st))", "X = list(input())", "X", "list(input())", "list", "input()", "input", "st = []", "st", "[]", "for x in X:\n if x == 'S':\n st.append(x)\n else:\n if len(st) > 0 and st[-1] == 'S':\n st.pop()\n else:\n st.append(x)", "x", "X", "if x == 'S':\n st.append(x)\n else:\n if len(st) > 0 and st[-1] == 'S':\n st.pop()\n else:\n st.append(x)", "x == 'S'", "x", "'S'", "st.append(x)", "st.append", "st", "append", "x", "if len(st) > 0 and st[-1] == 'S':\n st.pop()\n else:\n st.append(x)", "len(st) > 0 and st[-1] == 'S'", "len(st) > 0", "len(st)", "len", "st", "0", "st[-1] == 'S'", "st[-1]", "st", "-1", "'S'", "st.pop()", "st.pop", "st", "pop", "st.append(x)", "st.append", "st", "append", "x", "print(len(st))", "print", "len(st)", "len", "st", "X = list(input())", "list(input())", "X", "st = []", "[]", "st" ]
X = list(input()) st = [] for x in X: if x == 'S': st.append(x) else: if len(st) > 0 and st[-1] == 'S': st.pop() else: st.append(x) print(len(st))
[ 7, 0, 13, 4, 18, 4, 13, 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 ]
[ [ 40, 2 ], [ 55, 9 ], [ 43, 12 ], [ 41, 15 ], [ 18, 17 ], [ 41, 17 ], [ 17, 21 ], [ 46, 24 ], [ 56, 28 ], [ 50, 28 ], [ 47, 28 ], [ 52, 31 ], [ 49, 34 ], [ 53, 38 ], [ 44, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ] ]
[ "X = input().rstrip()\ncnt = 0\nres = len(X)\nfor x in X:\n if x==\"S\":\n cnt += 1\n else:\n if cnt > 0:\n res -= 2\n cnt -= 1\nprint(res)", "X = input().rstrip()", "X", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "cnt = 0", "cnt", "0", "res = len(X)", "res", "len(X)", "len", "X", "for x in X:\n if x==\"S\":\n cnt += 1\n else:\n if cnt > 0:\n res -= 2\n cnt -= 1", "x", "X", "if x==\"S\":\n cnt += 1\n else:\n if cnt > 0:\n res -= 2\n cnt -= 1", "x==\"S\"", "x", "\"S\"", "cnt += 1", "cnt", "1", "if cnt > 0:\n res -= 2\n cnt -= 1", "cnt > 0", "cnt", "0", "res -= 2", "res", "2", "cnt -= 1", "cnt", "1", "print(res)", "print", "res", "X = input().rstrip()", "input().rstrip()", "X", "res = len(X)", "len(X)", "res", "cnt += 1", "1", "cnt", "cnt -= 1", "1", "cnt", "res -= 2", "2", "res", "cnt = 0", "0", "cnt" ]
X = input().rstrip() cnt = 0 res = len(X) for x in X: if x=="S": cnt += 1 else: if cnt > 0: res -= 2 cnt -= 1 print(res)
[ 7, 15, 15, 15, 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, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 8, 7 ], [ 12, 11 ], [ 15, 14 ], [ 18, 17 ], [ 7, 17 ], [ 17, 21 ], [ 25, 24 ], [ 28, 27 ], [ 31, 30 ], [ 11, 33 ], [ 30, 33 ], [ 27, 34 ], [ 24, 34 ], [ 14, 34 ], [ 30, 38 ], [ 11, 38 ], [ 48, 45 ] ]
[ "#!/usr/bin/env python3\nfrom collections import deque, Counter\nfrom heapq import heappop, heappush\nfrom bisect import bisect_right\n\ndef main():\n X = input()\n ans = 0\n now = 0\n for x in X:\n if x == 'S':\n now -= 1\n else:\n now += 1\n ans = max(ans,now)\n print(ans*2)\n\nif __name__ == \"__main__\":\n main()", "from collections import deque, Counter", "from heapq import heappop, heappush", "from bisect import bisect_right", "def main():\n X = input()\n ans = 0\n now = 0\n for x in X:\n if x == 'S':\n now -= 1\n else:\n now += 1\n ans = max(ans,now)\n print(ans*2)", "main", "X = input()", "X", "input()", "input", "ans = 0", "ans", "0", "now = 0", "now", "0", "for x in X:\n if x == 'S':\n now -= 1\n else:\n now += 1\n ans = max(ans,now)\n ", "x", "X", "if x == 'S':\n now -= 1\n else:\n now += 1\n ", "x == 'S'", "x", "'S'", "now -= 1", "now", "1", "now += 1", "now", "1", "ans = max(ans,now)", "ans", "max(ans,now)", "max", "ans", "now", "print(ans*2)", "print", "ans*2", "ans", "2", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n X = input()\n ans = 0\n now = 0\n for x in X:\n if x == 'S':\n now -= 1\n else:\n now += 1\n ans = max(ans,now)\n print(ans*2)", "def main():\n X = input()\n ans = 0\n now = 0\n for x in X:\n if x == 'S':\n now -= 1\n else:\n now += 1\n ans = max(ans,now)\n print(ans*2)", "main" ]
#!/usr/bin/env python3 from collections import deque, Counter from heapq import heappop, heappush from bisect import bisect_right def main(): X = input() ans = 0 now = 0 for x in X: if x == 'S': now -= 1 else: now += 1 ans = max(ans,now) print(ans*2) if __name__ == "__main__": main()
[ 7, 0, 13, 4, 13, 0, 13, 39, 18, 13, 17, 28, 13, 18, 13, 39, 17, 14, 2, 13, 17, 0, 13, 39, 13, 14, 40, 13, 0, 13, 39, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 0, 13, 39, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 39, 13, 10, 39, 13, 10, 39, 13 ]
[ [ 55, 2 ], [ 64, 6 ], [ 56, 9 ], [ 13, 12 ], [ 56, 14 ], [ 12, 19 ], [ 61, 22 ], [ 65, 27 ], [ 59, 27 ], [ 53, 27 ], [ 62, 27 ], [ 52, 29 ], [ 65, 35 ], [ 59, 35 ], [ 53, 35 ], [ 62, 35 ], [ 65, 40 ], [ 59, 40 ], [ 53, 40 ], [ 62, 40 ], [ 58, 43 ], [ 59, 50 ], [ 53, 50 ], [ 62, 50 ], [ 65, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "x = input()\nres = [x[0]]\nfor i in x[1:]:\n if i == 'S':\n res += [i]\n elif not res:\n res += [i]\n else:\n if res[-1] == 'S':\n res.pop()\n else:\n res += [i]\nprint(len(res))", "x = input()", "x", "input()", "input", "res = [x[0]]", "res", "[x[0]]", "x[0]", "x", "0", "for i in x[1:]:\n if i == 'S':\n res += [i]\n elif not res:\n res += [i]\n else:\n if res[-1] == 'S':\n res.pop()\n else:\n res += [i]", "i", "x[1:]", "x", "1:", "1", "if i == 'S':\n res += [i]\n elif not res:\n res += [i]\n else:\n if res[-1] == 'S':\n res.pop()\n else:\n res += [i]", "i == 'S'", "i", "'S'", "res += [i]", "res", "[i]", "i", "elif not res:\n res += [i]\n ", "not res", "res", "res += [i]", "res", "[i]", "i", "if res[-1] == 'S':\n res.pop()\n else:\n res += [i]", "res[-1] == 'S'", "res[-1]", "res", "-1", "'S'", "res.pop()", "res.pop", "res", "pop", "res += [i]", "res", "[i]", "i", "print(len(res))", "print", "len(res)", "len", "res", "res += [i]", "[i]", "res", "x = input()", "input()", "x", "res += [i]", "[i]", "res", "res += [i]", "[i]", "res", "res = [x[0]]", "[x[0]]", "res" ]
x = input() res = [x[0]] for i in x[1:]: if i == 'S': res += [i] elif not res: res += [i] else: if res[-1] == 'S': res.pop() else: res += [i] print(len(res))
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 53, 2 ], [ 50, 6 ], [ 62, 9 ], [ 13, 12 ], [ 54, 17 ], [ 54, 21 ], [ 12, 22 ], [ 51, 26 ], [ 57, 26 ], [ 69, 26 ], [ 60, 26 ], [ 68, 29 ], [ 56, 32 ], [ 59, 35 ], [ 60, 39 ], [ 51, 39 ], [ 57, 39 ], [ 69, 39 ], [ 65, 42 ], [ 66, 47 ], [ 63, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "x = input()\n\ncontinus_s = 0\nliving_t_cnt = 0\nfor i in range(len(x)):\n if x[i] == 'S':\n if continus_s > 0:\n continus_s = 0\n continus_s -= 1\n else:\n continus_s += 1\n if continus_s > 0:\n living_t_cnt += 1\nprint(living_t_cnt*2)", "x = input()", "x", "input()", "input", "continus_s = 0", "continus_s", "0", "living_t_cnt = 0", "living_t_cnt", "0", "for i in range(len(x)):\n if x[i] == 'S':\n if continus_s > 0:\n continus_s = 0\n continus_s -= 1\n else:\n continus_s += 1\n if continus_s > 0:\n living_t_cnt += 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == 'S':\n if continus_s > 0:\n continus_s = 0\n continus_s -= 1\n else:\n continus_s += 1\n if continus_s > 0:\n living_t_cnt += 1", "x[i] == 'S'", "x[i]", "x", "i", "'S'", "if continus_s > 0:\n continus_s = 0\n ", "continus_s > 0", "continus_s", "0", "continus_s = 0", "continus_s", "0", "continus_s -= 1", "continus_s", "1", "continus_s += 1", "continus_s", "1", "if continus_s > 0:\n living_t_cnt += 1", "continus_s > 0", "continus_s", "0", "living_t_cnt += 1", "living_t_cnt", "1", "print(living_t_cnt*2)", "print", "living_t_cnt*2", "living_t_cnt", "2", "continus_s = 0", "0", "continus_s", "x = input()", "input()", "x", "continus_s -= 1", "1", "continus_s", "continus_s += 1", "1", "continus_s", "living_t_cnt = 0", "0", "living_t_cnt", "living_t_cnt += 1", "1", "living_t_cnt", "continus_s = 0", "0", "continus_s" ]
x = input() continus_s = 0 living_t_cnt = 0 for i in range(len(x)): if x[i] == 'S': if continus_s > 0: continus_s = 0 continus_s -= 1 else: continus_s += 1 if continus_s > 0: living_t_cnt += 1 print(living_t_cnt*2)
[ 7, 0, 13, 4, 13, 0, 13, 17, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 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 ]
[ [ 50, 2 ], [ 53, 6 ], [ 56, 8 ], [ 12, 11 ], [ 51, 11 ], [ 11, 15 ], [ 59, 18 ], [ 54, 23 ], [ 48, 23 ], [ 60, 23 ], [ 11, 26 ], [ 44, 29 ], [ 47, 32 ], [ 51, 39 ], [ 45, 41 ], [ 57, 41 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "s = input()\nstack, p = 0, 0\nfor i in s:\n if i == \"S\":\n stack += 1\n elif stack > 0 and i == \"T\":\n p += 1\n stack -= 1\n else:\n pass\nprint(len(s) - p * 2)", "s = input()", "s", "input()", "input", "stack, p = 0, 0", "stack", "0", "p", "0", "for i in s:\n if i == \"S\":\n stack += 1\n elif stack > 0 and i == \"T\":\n p += 1\n stack -= 1\n else:\n pass", "i", "s", "if i == \"S\":\n stack += 1\n elif stack > 0 and i == \"T\":\n p += 1\n stack -= 1\n else:\n pass", "i == \"S\"", "i", "\"S\"", "stack += 1", "stack", "1", "elif stack > 0 and i == \"T\":\n p += 1\n stack -= 1\n ", "stack > 0 and i == \"T\"", "stack > 0", "stack", "0", "i == \"T\"", "i", "\"T\"", "p += 1", "p", "1", "stack -= 1", "stack", "1", "print(len(s) - p * 2)", "print", "len(s) - p * 2", "len(s)", "len", "s", "p * 2", "p", "2", "p += 1", "1", "p", "stack -= 1", "1", "stack", "s = input()", "input()", "s", "stack, p = 0, 0", "0", "stack", "p = 0, 0", "0", "p", "stack += 1", "1", "stack" ]
s = input() stack, p = 0, 0 for i in s: if i == "S": stack += 1 elif stack > 0 and i == "T": p += 1 stack -= 1 else: pass print(len(s) - p * 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, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 53, 2 ], [ 44, 6 ], [ 56, 9 ], [ 13, 12 ], [ 54, 17 ], [ 54, 21 ], [ 12, 22 ], [ 45, 26 ], [ 51, 26 ], [ 50, 29 ], [ 47, 32 ], [ 54, 39 ], [ 48, 41 ], [ 57, 41 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "x = input()\ns = 0\ncnt = 0\nfor i in range(len(x)):\n if x[i] == \"S\": s += 1\n else:\n if s > 0: \n s -= 1\n cnt += 1\nprint(len(x)-cnt*2)", "x = input()", "x", "input()", "input", "s = 0", "s", "0", "cnt = 0", "cnt", "0", "for i in range(len(x)):\n if x[i] == \"S\": s += 1\n else:\n if s > 0: \n s -= 1\n cnt += 1", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == \"S\": s += 1\n else:\n if s > 0: \n s -= 1\n cnt += 1", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "if s > 0: \n s -= 1\n cnt += 1", "s > 0", "s", "0", "s -= 1", "s", "1", "cnt += 1", "cnt", "1", "print(len(x)-cnt*2)", "print", "len(x)-cnt*2", "len(x)", "len", "x", "cnt*2", "cnt", "2", "s = 0", "0", "s", "cnt += 1", "1", "cnt", "s -= 1", "1", "s", "x = input()", "input()", "x", "cnt = 0", "0", "cnt" ]
x = input() s = 0 cnt = 0 for i in range(len(x)): if x[i] == "S": s += 1 else: if s > 0: s -= 1 cnt += 1 print(len(x)-cnt*2)
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 40, 4, 13, 13, 17, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 55, 2 ], [ 52, 6 ], [ 10, 9 ], [ 56, 9 ], [ 9, 13 ], [ 53, 17 ], [ 9, 19 ], [ 53, 24 ], [ 53, 29 ], [ 53, 34 ], [ 53, 38 ], [ 9, 40 ], [ 53, 43 ], [ 9, 45 ], [ 53, 50 ], [ 52, 53 ], [ 55, 56 ] ]
[ "X = input()\nans = []\nfor x in X:\n if x == 'S':\n ans.append(x)\n else:\n if len(ans) != 0:\n if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x)\n else:\n ans.append(x)\nprint(len(ans))", "X = input()", "X", "input()", "input", "ans = []", "ans", "[]", "for x in X:\n if x == 'S':\n ans.append(x)\n else:\n if len(ans) != 0:\n if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x)\n else:\n ans.append(x)", "x", "X", "if x == 'S':\n ans.append(x)\n else:\n if len(ans) != 0:\n if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x)\n else:\n ans.append(x)", "x == 'S'", "x", "'S'", "ans.append(x)", "ans.append", "ans", "append", "x", "if len(ans) != 0:\n if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x)\n else:\n ans.append(x)", "len(ans) != 0", "len(ans)", "len", "ans", "0", "if ans[-1] == 'S':\n ans.pop()\n else:\n ans.append(x)\n ", "ans[-1] == 'S'", "ans[-1]", "ans", "-1", "'S'", "ans.pop()", "ans.pop", "ans", "pop", "ans.append(x)", "ans.append", "ans", "append", "x", "ans.append(x)", "ans.append", "ans", "append", "x", "print(len(ans))", "print", "len(ans)", "len", "ans", "ans = []", "[]", "ans", "X = input()", "input()", "X" ]
X = input() ans = [] for x in X: if x == 'S': ans.append(x) else: if len(ans) != 0: if ans[-1] == 'S': ans.pop() else: ans.append(x) else: ans.append(x) print(len(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, 0, 13, 4, 13, 13, 13, 0, 13, 17, 4, 13, 2, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 57, 2 ], [ 48, 6 ], [ 42, 9 ], [ 13, 12 ], [ 58, 17 ], [ 58, 21 ], [ 12, 22 ], [ 51, 25 ], [ 54, 28 ], [ 43, 31 ], [ 55, 31 ], [ 52, 32 ], [ 49, 32 ], [ 46, 32 ], [ 45, 34 ], [ 55, 40 ], [ 43, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "S=input()\nscore=0\nmaxscore=0\nfor i in range(len(S)):\n if S[i]=='T':\n score+=1\n maxscore=max(maxscore,score)\n else:\n score-=1\nprint(2*maxscore)", "S=input()", "S", "input()", "input", "score=0", "score", "0", "maxscore=0", "maxscore", "0", "for i in range(len(S)):\n if S[i]=='T':\n score+=1\n maxscore=max(maxscore,score)\n else:\n score-=1", "i", "range(len(S))", "range", "len(S)", "len", "S", "if S[i]=='T':\n score+=1\n maxscore=max(maxscore,score)\n else:\n score-=1", "S[i]=='T'", "S[i]", "S", "i", "'T'", "score+=1", "score", "1", "maxscore=max(maxscore,score)", "maxscore", "max(maxscore,score)", "max", "maxscore", "score", "score-=1", "score", "1", "print(2*maxscore)", "print", "2*maxscore", "2", "maxscore", "maxscore=0", "0", "maxscore", "score-=1", "1", "score", "score=0", "0", "score", "score+=1", "1", "score", "maxscore=max(maxscore,score)", "max(maxscore,score)", "maxscore", "S=input()", "input()", "S" ]
S=input() score=0 maxscore=0 for i in range(len(S)): if S[i]=='T': score+=1 maxscore=max(maxscore,score) else: score-=1 print(2*maxscore)
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 23, 13, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 12, 13, 23, 13, 23, 13, 17, 0, 13, 4, 13, 17, 15, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 39, 28, 13, 13, 14, 40, 13, 4, 18, 13, 13, 13, 9, 14, 2, 13, 17, 0, 13, 4, 18, 13, 13, 14, 2, 13, 17, 9, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 13, 13 ], [ 27, 26 ], [ 128, 32 ], [ 36, 36 ], [ 44, 43 ], [ 158, 49 ], [ 53, 53 ], [ 57, 57 ], [ 60, 59 ], [ 154, 62 ], [ 71, 70 ], [ 75, 74 ], [ 80, 79 ], [ 70, 79 ], [ 74, 83 ], [ 74, 86 ], [ 79, 88 ], [ 79, 92 ], [ 96, 95 ], [ 74, 98 ], [ 95, 102 ], [ 74, 107 ], [ 95, 109 ], [ 74, 112 ], [ 79, 114 ], [ 74, 119 ], [ 161, 125 ], [ 154, 155 ] ]
[ "import sys\nsys.setrecursionlimit(10 ** 9)\n# input = sys.stdin.readline ####\ndef int1(x): return int(x) - 1\ndef II(): return int(input())\ndef MI(): return map(int, input().split())\ndef MI1(): return map(int1, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef MS(): return input().split()\ndef LS(): return list(input())\ndef LLS(rows_number): return [LS() for _ in range(rows_number)]\ndef printlist(lst, k=' '): print(k.join(list(map(str, lst))))\nINF = float('inf')\n# from math import ceil, floor, log2\nfrom collections import deque, defaultdict\n# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations\n# from heapq import heapify, heappop, heappush\n# import numpy as np # cumsum\n# from bisect import bisect_left, bisect_right\n\ndef solve():\n X = input()\n # print(X)\n\n L = deque([])\n for now in X:\n if not L:\n L.append(now)\n continue\n\n if now == 'T':\n pre = L.pop()\n if pre == 'S':\n continue\n else:\n L.append(pre)\n L.append(now)\n\n print(len(L))\n\n\nif __name__ == '__main__':\n solve()\n", "import sys", "sys", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "def int1(x): return int(x) - 1", "int1", "x", "x", "def II(): return int(input())", "II", "def MI(): return map(int, input().split())", "MI", "def MI1(): return map(int1, input().split())", "MI1", "def LI(): return list(map(int, input().split()))", "LI", "def LI1(): return list(map(int1, input().split()))", "LI1", "LI() for _ in range(rows_number)", "for _ in range(rows_number)", "_", "range(rows_number)", "range", "rows_number", "for _ in range(rows_number)", "LI()", "LI", "def LLI(rows_number): return [LI() for _ in range(rows_number)]", "LLI", "rows_number", "rows_number", "def MS(): return input().split()", "MS", "def LS(): return list(input())", "LS", "LS() for _ in range(rows_number)", "for _ in range(rows_number)", "_", "range(rows_number)", "range", "rows_number", "for _ in range(rows_number)", "LS()", "LS", "def LLS(rows_number): return [LS() for _ in range(rows_number)]", "LLS", "rows_number", "rows_number", "def printlist(lst, k=' '): print(k.join(list(map(str, lst))))", "printlist", "lst", "lst", "k=' '", "k", "' '", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "from collections import deque, defaultdict", "def solve():\n X = input()\n # print(X)\n\n L = deque([])\n for now in X:\n if not L:\n L.append(now)\n continue\n\n if now == 'T':\n pre = L.pop()\n if pre == 'S':\n continue\n else:\n L.append(pre)\n L.append(now)\n\n print(len(L))", "solve", "X = input()", "X", "input()", "input", "L = deque([])", "L", "deque([])", "deque", "[]", "for now in X:\n if not L:\n L.append(now)\n continue\n\n if now == 'T':\n pre = L.pop()\n if pre == 'S':\n continue\n else:\n L.append(pre)\n L.append(now)\n\n ", "now", "X", "if not L:\n L.append(now)\n continue\n\n ", "not L", "L", "L.append(now)", "L.append", "L", "append", "now", "continue", "if now == 'T':\n pre = L.pop()\n if pre == 'S':\n continue\n else:\n L.append(pre)\n ", "now == 'T'", "now", "'T'", "pre = L.pop()", "pre", "L.pop()", "L.pop", "L", "pop", "if pre == 'S':\n continue\n else:\n L.append(pre)\n ", "pre == 'S'", "pre", "'S'", "continue", "L.append(pre)", "L.append", "L", "append", "pre", "L.append(now)", "L.append", "L", "append", "now", "print(len(L))", "print", "len(L)", "len", "L", "if __name__ == '__main__':\n solve()", "__name__ == '__main__'", "__name__", "'__main__'", "solve()", "solve", "def LI(): return list(map(int, input().split()))", "def LI(): return list(map(int, input().split()))", "LI", "def LI1(): return list(map(int1, input().split()))", "def LI1(): return list(map(int1, input().split()))", "LI1", "def int1(x): return int(x) - 1", "def int1(x): return int(x) - 1", "int1", "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 LLI(rows_number): return [LI() for _ in range(rows_number)]", "def LLI(rows_number): return [LI() for _ in range(rows_number)]", "LLI", "def MI1(): return map(int1, input().split())", "def MI1(): return map(int1, input().split())", "MI1", "def printlist(lst, k=' '): print(k.join(list(map(str, lst))))", "def printlist(lst, k=' '): print(k.join(list(map(str, lst))))", "printlist", "def LLS(rows_number): return [LS() for _ in range(rows_number)]", "def LLS(rows_number): return [LS() for _ in range(rows_number)]", "LLS", "INF = float('inf')", "float('inf')", "INF", "def LS(): return list(input())", "def LS(): return list(input())", "LS", "def solve():\n X = input()\n # print(X)\n\n L = deque([])\n for now in X:\n if not L:\n L.append(now)\n continue\n\n if now == 'T':\n pre = L.pop()\n if pre == 'S':\n continue\n else:\n L.append(pre)\n L.append(now)\n\n print(len(L))", "def solve():\n X = input()\n # print(X)\n\n L = deque([])\n for now in X:\n if not L:\n L.append(now)\n continue\n\n if now == 'T':\n pre = L.pop()\n if pre == 'S':\n continue\n else:\n L.append(pre)\n L.append(now)\n\n print(len(L))", "solve", "def MS(): return input().split()", "def MS(): return input().split()", "MS" ]
import sys sys.setrecursionlimit(10 ** 9) # input = sys.stdin.readline #### def int1(x): return int(x) - 1 def II(): return int(input()) def MI(): return map(int, input().split()) def MI1(): return map(int1, input().split()) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def MS(): return input().split() def LS(): return list(input()) def LLS(rows_number): return [LS() for _ in range(rows_number)] def printlist(lst, k=' '): print(k.join(list(map(str, lst)))) INF = float('inf') # from math import ceil, floor, log2 from collections import deque, defaultdict # from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations # from heapq import heapify, heappop, heappush # import numpy as np # cumsum # from bisect import bisect_left, bisect_right def solve(): X = input() # print(X) L = deque([]) for now in X: if not L: L.append(now) continue if now == 'T': pre = L.pop() if pre == 'S': continue else: L.append(pre) L.append(now) print(len(L)) if __name__ == '__main__': solve()
[ 7, 0, 13, 18, 4, 13, 39, 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, 0, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 57, 2 ], [ 51, 9 ], [ 58, 12 ], [ 60, 14 ], [ 54, 17 ], [ 21, 20 ], [ 52, 23 ], [ 58, 27 ], [ 20, 28 ], [ 63, 31 ], [ 48, 34 ], [ 66, 37 ], [ 55, 40 ], [ 67, 40 ], [ 49, 41 ], [ 64, 41 ], [ 61, 41 ], [ 67, 45 ], [ 55, 45 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "s = input()[::-1]\nn = len(s)\ntmp = 0\nans = 0\nfor i in range(n):\n if s[i] == 'S':\n tmp += 1\n else:\n tmp -= 1\n ans = max(ans, tmp)\n\nprint(ans * 2)", "s = input()[::-1]", "s", "input()[::-1]", "()", "input", "::-1", "-1", "n = len(s)", "n", "len(s)", "len", "s", "tmp = 0", "tmp", "0", "ans = 0", "ans", "0", "for i in range(n):\n if s[i] == 'S':\n tmp += 1\n else:\n tmp -= 1\n ans = max(ans, tmp)", "i", "range(n)", "range", "n", "if s[i] == 'S':\n tmp += 1\n else:\n tmp -= 1\n ", "s[i] == 'S'", "s[i]", "s", "i", "'S'", "tmp += 1", "tmp", "1", "tmp -= 1", "tmp", "1", "ans = max(ans, tmp)", "ans", "max(ans, tmp)", "max", "ans", "tmp", "print(ans * 2)", "print", "ans * 2", "ans", "2", "tmp -= 1", "1", "tmp", "n = len(s)", "len(s)", "n", "ans = 0", "0", "ans", "s = input()[::-1]", "input()[::-1]", "s", "tmp = 0", "0", "tmp", "tmp += 1", "1", "tmp", "ans = max(ans, tmp)", "max(ans, tmp)", "ans" ]
s = input()[::-1] n = len(s) tmp = 0 ans = 0 for i in range(n): if s[i] == 'S': tmp += 1 else: tmp -= 1 ans = max(ans, tmp) print(ans * 2)
[ 7, 0, 13, 4, 13, 0, 13, 17, 42, 2, 2, 4, 13, 13, 17, 13, 14, 2, 2, 18, 13, 13, 17, 2, 18, 13, 2, 13, 17, 17, 0, 13, 2, 18, 13, 39, 13, 18, 13, 39, 2, 13, 17, 0, 13, 4, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 63, 2 ], [ 69, 6 ], [ 64, 13 ], [ 61, 13 ], [ 70, 15 ], [ 67, 15 ], [ 73, 15 ], [ 64, 20 ], [ 61, 20 ], [ 70, 21 ], [ 67, 21 ], [ 73, 21 ], [ 64, 25 ], [ 61, 25 ], [ 70, 27 ], [ 67, 27 ], [ 73, 27 ], [ 60, 31 ], [ 64, 34 ], [ 61, 34 ], [ 64, 38 ], [ 61, 38 ], [ 70, 41 ], [ 67, 41 ], [ 73, 41 ], [ 72, 44 ], [ 70, 49 ], [ 67, 49 ], [ 73, 49 ], [ 66, 52 ], [ 61, 58 ], [ 64, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "x = input()\n\ncnt = 0\n\nwhile len(x) - 1 > cnt:\n if x[cnt] == 'S' and x[cnt+1] == 'T':\n x = x[:cnt] + x[cnt+2:]\n cnt = max(0, cnt - 1)\n else:\n cnt += 1\n\nprint(len(x))", "x = input()", "x", "input()", "input", "cnt = 0", "cnt", "0", "while len(x) - 1 > cnt:\n if x[cnt] == 'S' and x[cnt+1] == 'T':\n x = x[:cnt] + x[cnt+2:]\n cnt = max(0, cnt - 1)\n else:\n cnt += 1", "len(x) - 1 > cnt", "len(x) - 1", "len(x)", "len", "x", "1", "cnt", "if x[cnt] == 'S' and x[cnt+1] == 'T':\n x = x[:cnt] + x[cnt+2:]\n cnt = max(0, cnt - 1)\n else:\n cnt += 1", "x[cnt] == 'S' and x[cnt+1] == 'T'", "x[cnt] == 'S'", "x[cnt]", "x", "cnt", "'S'", "x[cnt+1] == 'T'", "x[cnt+1]", "x", "cnt+1", "cnt", "1", "'T'", "x = x[:cnt] + x[cnt+2:]", "x", "x[:cnt] + x[cnt+2:]", "x[:cnt]", "x", ":cnt", "cnt", "x[cnt+2:]", "x", "cnt+2:", "cnt+2", "cnt", "2", "cnt = max(0, cnt - 1)", "cnt", "max(0, cnt - 1)", "max", "0", "cnt - 1", "cnt", "1", "cnt += 1", "cnt", "1", "print(len(x))", "print", "len(x)", "len", "x", "x = x[:cnt] + x[cnt+2:]", "x[:cnt] + x[cnt+2:]", "x", "x = input()", "input()", "x", "cnt += 1", "1", "cnt", "cnt = 0", "0", "cnt", "cnt = max(0, cnt - 1)", "max(0, cnt - 1)", "cnt" ]
x = input() cnt = 0 while len(x) - 1 > cnt: if x[cnt] == 'S' and x[cnt+1] == 'T': x = x[:cnt] + x[cnt+2:] cnt = max(0, cnt - 1) else: cnt += 1 print(len(x))
[ 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 ], [ 49, 6 ], [ 52, 9 ], [ 13, 12 ], [ 44, 17 ], [ 44, 21 ], [ 12, 22 ], [ 55, 25 ], [ 50, 29 ], [ 47, 29 ], [ 56, 29 ], [ 58, 32 ], [ 46, 35 ], [ 47, 40 ], [ 56, 40 ], [ 50, 40 ], [ 59, 41 ], [ 53, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "X = input()\n\nleft_S = 0\nleft_T = 0\n\nfor i in range(len(X)):\n if X[i] == \"S\":\n left_S += 1\n elif left_S == 0:\n left_T += 1\n else:\n left_S -= 1\n\nprint(left_S + left_T)", "X = input()", "X", "input()", "input", "left_S = 0", "left_S", "0", "left_T = 0", "left_T", "0", "for i in range(len(X)):\n if X[i] == \"S\":\n left_S += 1\n elif left_S == 0:\n left_T += 1\n else:\n left_S -= 1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == \"S\":\n left_S += 1\n elif left_S == 0:\n left_T += 1\n else:\n left_S -= 1", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "left_S += 1", "left_S", "1", "elif left_S == 0:\n left_T += 1\n ", "left_S == 0", "left_S", "0", "left_T += 1", "left_T", "1", "left_S -= 1", "left_S", "1", "print(left_S + left_T)", "print", "left_S + left_T", "left_S", "left_T", "X = input()", "input()", "X", "left_S -= 1", "1", "left_S", "left_S = 0", "0", "left_S", "left_T = 0", "0", "left_T", "left_S += 1", "1", "left_S", "left_T += 1", "1", "left_T" ]
X = input() left_S = 0 left_T = 0 for i in range(len(X)): if X[i] == "S": left_S += 1 elif left_S == 0: left_T += 1 else: left_S -= 1 print(left_S + left_T)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 39, 28, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 13, 14, 2, 2, 18, 13, 17, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 42, 3 ], [ 39, 7 ], [ 13, 12 ], [ 43, 12 ], [ 40, 18 ], [ 40, 22 ], [ 12, 24 ], [ 40, 29 ], [ 12, 31 ], [ 40, 37 ], [ 39, 40 ], [ 42, 43 ] ]
[ "from collections import deque\ns=input()\n\nA=deque([])\nfor i in s:\n if len(A)<1:\n A.append(i)\n else:\n if A[-1]+i==\"ST\":A.pop()\n else:A.append(i)\n\nprint(len(A))", "from collections import deque", "s=input()", "s", "input()", "input", "A=deque([])", "A", "deque([])", "deque", "[]", "for i in s:\n if len(A)<1:\n A.append(i)\n else:\n if A[-1]+i==\"ST\":A.pop()\n else:A.append(i)", "i", "s", "if len(A)<1:\n A.append(i)\n else:\n if A[-1]+i==\"ST\":A.pop()\n else:A.append(i)", "len(A)<1", "len(A)", "len", "A", "1", "A.append(i)", "A.append", "A", "append", "i", "if A[-1]+i==\"ST\":A.pop()\n else:A.append(i)", "A[-1]+i==\"ST\"", "A[-1]+i", "A[-1]", "A", "-1", "i", "\"ST\"", "print(len(A))", "print", "len(A)", "len", "A", "A=deque([])", "deque([])", "A", "s=input()", "input()", "s" ]
from collections import deque s=input() A=deque([]) for i in s: if len(A)<1: A.append(i) else: if A[-1]+i=="ST":A.pop() else:A.append(i) print(len(A))
[ 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, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 39, 2 ], [ 42, 6 ], [ 45, 9 ], [ 13, 12 ], [ 40, 12 ], [ 12, 16 ], [ 51, 19 ], [ 43, 23 ], [ 55, 23 ], [ 52, 23 ], [ 54, 26 ], [ 48, 29 ], [ 40, 36 ], [ 49, 37 ], [ 46, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ] ]
[ "X = input()\ns_count = 0\nans = 0\nfor i in X:\n if i == 'S':\n s_count += 1\n elif s_count > 0:\n s_count -= 1\n ans += 2\nprint(len(X)-ans)", "X = input()", "X", "input()", "input", "s_count = 0", "s_count", "0", "ans = 0", "ans", "0", "for i in X:\n if i == 'S':\n s_count += 1\n elif s_count > 0:\n s_count -= 1\n ans += 2", "i", "X", "if i == 'S':\n s_count += 1\n elif s_count > 0:\n s_count -= 1\n ans += 2", "i == 'S'", "i", "'S'", "s_count += 1", "s_count", "1", "elif s_count > 0:\n s_count -= 1\n ans += 2", "s_count > 0", "s_count", "0", "s_count -= 1", "s_count", "1", "ans += 2", "ans", "2", "print(len(X)-ans)", "print", "len(X)-ans", "len(X)", "len", "X", "ans", "X = input()", "input()", "X", "s_count = 0", "0", "s_count", "ans = 0", "0", "ans", "ans += 2", "2", "ans", "s_count += 1", "1", "s_count", "s_count -= 1", "1", "s_count" ]
X = input() s_count = 0 ans = 0 for i in X: if i == 'S': s_count += 1 elif s_count > 0: s_count -= 1 ans += 2 print(len(X)-ans)
[ 7, 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, 28, 13, 4, 13, 17, 4, 13, 13, 0, 18, 13, 13, 18, 13, 2, 13, 17, 0, 18, 13, 13, 18, 13, 2, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 4, 13, 13, 2, 17, 2, 18, 13, 13, 18, 13, 13, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 98, 2 ], [ 101, 6 ], [ 99, 12 ], [ 107, 14 ], [ 99, 20 ], [ 23, 22 ], [ 99, 27 ], [ 99, 31 ], [ 22, 32 ], [ 38, 35 ], [ 102, 36 ], [ 22, 37 ], [ 43, 40 ], [ 108, 41 ], [ 22, 42 ], [ 46, 45 ], [ 99, 51 ], [ 56, 53 ], [ 102, 54 ], [ 45, 55 ], [ 102, 57 ], [ 45, 59 ], [ 65, 62 ], [ 108, 63 ], [ 45, 64 ], [ 108, 66 ], [ 45, 68 ], [ 104, 71 ], [ 75, 74 ], [ 99, 79 ], [ 110, 81 ], [ 105, 84 ], [ 111, 84 ], [ 62, 88 ], [ 40, 88 ], [ 108, 89 ], [ 74, 90 ], [ 53, 91 ], [ 35, 91 ], [ 102, 92 ], [ 74, 93 ], [ 111, 96 ], [ 105, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ], [ 110, 111 ] ]
[ "U = input()\nS = [0]*len(U)\nT = [0]*len(U)\nfor k in range(len(U)):\n if U[k] == \"S\":\n S[k] = 1\n else:\n T[k] = 1\n\nfor k in range(1,len(U)):\n S[k] += S[k-1]\n T[k] += T[k-1]\nans = 0\nfor k in range(len(U)):\n ans = max(ans,2*(T[k]-S[k]))\nprint(ans)", "U = input()", "U", "input()", "input", "S = [0]*len(U)", "S", "[0]*len(U)", "[0]", "0", "len(U)", "len", "U", "T = [0]*len(U)", "T", "[0]*len(U)", "[0]", "0", "len(U)", "len", "U", "for k in range(len(U)):\n if U[k] == \"S\":\n S[k] = 1\n else:\n T[k] = 1", "k", "range(len(U))", "range", "len(U)", "len", "U", "if U[k] == \"S\":\n S[k] = 1\n else:\n T[k] = 1", "U[k] == \"S\"", "U[k]", "U", "k", "\"S\"", "S[k] = 1", "S[k]", "S", "k", "1", "T[k] = 1", "T[k]", "T", "k", "1", "for k in range(1,len(U)):\n S[k] += S[k-1]\n T[k] += T[k-1]", "k", "range(1,len(U))", "range", "1", "len(U)", "len", "U", "S[k] += S[k-1]", "S[k]", "S", "k", "S[k-1]", "S", "k-1", "k", "1", "T[k] += T[k-1]", "T[k]", "T", "k", "T[k-1]", "T", "k-1", "k", "1", "ans = 0", "ans", "0", "for k in range(len(U)):\n ans = max(ans,2*(T[k]-S[k]))", "k", "range(len(U))", "range", "len(U)", "len", "U", "ans = max(ans,2*(T[k]-S[k]))", "ans", "max(ans,2*(T[k]-S[k]))", "max", "ans", "2*(T[k]-S[k])", "2", "T[k]-S[k]", "T[k]", "T", "k", "S[k]", "S", "k", "print(ans)", "print", "ans", "U = input()", "input()", "U", "S = [0]*len(U)", "[0]*len(U)", "S", "ans = 0", "0", "ans", "T = [0]*len(U)", "[0]*len(U)", "T", "ans = max(ans,2*(T[k]-S[k]))", "max(ans,2*(T[k]-S[k]))", "ans" ]
U = input() S = [0]*len(U) T = [0]*len(U) for k in range(len(U)): if U[k] == "S": S[k] = 1 else: T[k] = 1 for k in range(1,len(U)): S[k] += S[k-1] T[k] += T[k-1] ans = 0 for k in range(len(U)): ans = max(ans,2*(T[k]-S[k])) print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 13, 14, 2, 2, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 48, 2 ], [ 51, 6 ], [ 10, 9 ], [ 49, 9 ], [ 52, 15 ], [ 52, 19 ], [ 9, 21 ], [ 9, 25 ], [ 52, 29 ], [ 52, 34 ], [ 52, 39 ], [ 9, 41 ], [ 52, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "x = input()\n\nstack = []\n\nfor c in x:\n if len(stack) == 0:\n stack.append(c)\n elif c == \"T\" and stack[-1] == \"S\":\n stack.pop(-1)\n else:\n stack.append(c)\n\nprint(len(stack))", "x = input()", "x", "input()", "input", "stack = []", "stack", "[]", "for c in x:\n if len(stack) == 0:\n stack.append(c)\n elif c == \"T\" and stack[-1] == \"S\":\n stack.pop(-1)\n else:\n stack.append(c)", "c", "x", "if len(stack) == 0:\n stack.append(c)\n elif c == \"T\" and stack[-1] == \"S\":\n stack.pop(-1)\n else:\n stack.append(c)", "len(stack) == 0", "len(stack)", "len", "stack", "0", "stack.append(c)", "stack.append", "stack", "append", "c", "elif c == \"T\" and stack[-1] == \"S\":\n stack.pop(-1)\n ", "c == \"T\" and stack[-1] == \"S\"", "c == \"T\"", "c", "\"T\"", "stack[-1] == \"S\"", "stack[-1]", "stack", "-1", "\"S\"", "stack.pop(-1)", "stack.pop", "stack", "pop", "-1", "stack.append(c)", "stack.append", "stack", "append", "c", "print(len(stack))", "print", "len(stack)", "len", "stack", "x = input()", "input()", "x", "stack = []", "[]", "stack" ]
x = input() stack = [] for c in x: if len(stack) == 0: stack.append(c) elif c == "T" and stack[-1] == "S": stack.pop(-1) else: stack.append(c) print(len(stack))
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 12, 13, 12, 13, 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, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 17, 13, 29, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 15, 14 ], [ 14, 23 ], [ 30, 29 ], [ 34, 33 ], [ 40, 36 ], [ 40, 39 ], [ 43, 42 ], [ 29, 47 ], [ 29, 51 ], [ 42, 52 ], [ 56, 55 ], [ 59, 58 ], [ 62, 61 ], [ 39, 65 ], [ 68, 65 ], [ 58, 65 ], [ 69, 68 ], [ 72, 71 ], [ 29, 78 ], [ 71, 81 ], [ 36, 81 ], [ 91, 88 ] ]
[ "\nimport sys\nsys.setrecursionlimit(10 ** 8)\n\ndef Z(): return int(input())\ndef ZZ(): return [int(_) for _ in input().split()]\n\ndef main():\n X = input()\n s = False\n c = cc = 0\n for i in range(len(X)):\n if X[i] == 'S':\n s = True\n cc += 1\n else:\n s = False\n if cc > 0:\n cc -= 1\n c += 1\n print(len(X)-2*c)\n\n return\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "sys.setrecursionlimit(10 ** 8)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 8", "10", "8", "def Z(): return int(input())", "Z", "int(_) for _ in input().split()", "for _ in input().split()", "_", "input().split()", "().split", "()", "input", "split", "for _ in input().split()", "int(_)", "int", "_", "def ZZ(): return [int(_) for _ in input().split()]", "ZZ", "def main():\n X = input()\n s = False\n c = cc = 0\n for i in range(len(X)):\n if X[i] == 'S':\n s = True\n cc += 1\n else:\n s = False\n if cc > 0:\n cc -= 1\n c += 1\n print(len(X)-2*c)\n\n return", "main", "X = input()", "X", "input()", "input", "s = False", "s", "False", "c = cc = 0", "c", "0", "= cc = 0", "cc", "0", "for i in range(len(X)):\n if X[i] == 'S':\n s = True\n cc += 1\n else:\n s = False\n if cc > 0:\n cc -= 1\n c += 1\n ", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == 'S':\n s = True\n cc += 1\n else:\n s = False\n if cc > 0:\n cc -= 1\n c += 1\n ", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "s = True", "s", "True", "cc += 1", "cc", "1", "s = False", "s", "False", "if cc > 0:\n cc -= 1\n c += 1\n ", "cc > 0", "cc", "0", "cc -= 1", "cc", "1", "c += 1", "c", "1", "print(len(X)-2*c)", "print", "len(X)-2*c", "len(X)", "len", "X", "2*c", "2", "c", "return", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n X = input()\n s = False\n c = cc = 0\n for i in range(len(X)):\n if X[i] == 'S':\n s = True\n cc += 1\n else:\n s = False\n if cc > 0:\n cc -= 1\n c += 1\n print(len(X)-2*c)\n\n return", "def main():\n X = input()\n s = False\n c = cc = 0\n for i in range(len(X)):\n if X[i] == 'S':\n s = True\n cc += 1\n else:\n s = False\n if cc > 0:\n cc -= 1\n c += 1\n print(len(X)-2*c)\n\n return", "main", "def Z(): return int(input())", "def Z(): return int(input())", "Z", "def ZZ(): return [int(_) for _ in input().split()]", "def ZZ(): return [int(_) for _ in input().split()]", "ZZ" ]
import sys sys.setrecursionlimit(10 ** 8) def Z(): return int(input()) def ZZ(): return [int(_) for _ in input().split()] def main(): X = input() s = False c = cc = 0 for i in range(len(X)): if X[i] == 'S': s = True cc += 1 else: s = False if cc > 0: cc -= 1 c += 1 print(len(X)-2*c) return if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 0, 13, 39, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 17, 14, 2, 13, 17, 14, 13, 4, 18, 13, 13, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 10, 17, 13, 10, 4, 13, 10, 39, 13, 10, 17, 13 ]
[ [ 47, 2 ], [ 50, 6 ], [ 44, 9 ], [ 13, 12 ], [ 48, 12 ], [ 12, 16 ], [ 51, 20 ], [ 12, 25 ], [ 51, 31 ], [ 53, 34 ], [ 48, 41 ], [ 54, 42 ], [ 45, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "# https://atcoder.jp/contests/agc005/tasks/agc005_a\n\n# 'ST'を抜け。\n# 文字列を連長圧縮、先頭は必ずSを、最後には必ずTになるようにする(0個を許容)\n# そしたらSTSTSTSTの文字数なので二個ずつabs(n_s-n_t)を取っていけばよい。ただしTが先になくなるときは、Sの余りを次のSに移し替えなければ行けない\n# とかいろいろ考えたけどおとなしくstackで実装\n# ここでは何文字STができたかを数える\n\n\nX = input()\n\n# おとなしくstackで実装し直す\nstack = []\nn_poped = 0\nfor x in X:\n if x == 'S':\n stack.append(1)\n elif x == 'T':\n if stack:\n stack.pop()\n n_poped += 2\n\nprint(len(X) - n_poped)", "X = input()", "X", "input()", "input", "stack = []", "stack", "[]", "n_poped = 0", "n_poped", "0", "for x in X:\n if x == 'S':\n stack.append(1)\n elif x == 'T':\n if stack:\n stack.pop()\n n_poped += 2", "x", "X", "if x == 'S':\n stack.append(1)\n elif x == 'T':\n if stack:\n stack.pop()\n n_poped += 2", "x == 'S'", "x", "'S'", "stack.append(1)", "stack.append", "stack", "append", "1", "elif x == 'T':\n if stack:\n stack.pop()\n n_poped += 2", "x == 'T'", "x", "'T'", "if stack:\n stack.pop()\n n_poped += 2", "stack", "stack.pop()", "stack.pop", "stack", "pop", "n_poped += 2", "n_poped", "2", "print(len(X) - n_poped)", "print", "len(X) - n_poped", "len(X)", "len", "X", "n_poped", "n_poped = 0", "0", "n_poped", "X = input()", "input()", "X", "stack = []", "[]", "stack", "n_poped += 2", "2", "n_poped" ]
# https://atcoder.jp/contests/agc005/tasks/agc005_a # 'ST'を抜け。 # 文字列を連長圧縮、先頭は必ずSを、最後には必ずTになるようにする(0個を許容) # そしたらSTSTSTSTの文字数なので二個ずつabs(n_s-n_t)を取っていけばよい。ただしTが先になくなるときは、Sの余りを次のSに移し替えなければ行けない # とかいろいろ考えたけどおとなしくstackで実装 # ここでは何文字STができたかを数える X = input() # おとなしくstackで実装し直す stack = [] n_poped = 0 for x in X: if x == 'S': stack.append(1) elif x == 'T': if stack: stack.pop() n_poped += 2 print(len(X) - n_poped)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 39, 2 ], [ 51, 8 ], [ 40, 11 ], [ 48, 13 ], [ 17, 16 ], [ 40, 16 ], [ 16, 20 ], [ 54, 23 ], [ 49, 27 ], [ 43, 27 ], [ 55, 27 ], [ 45, 30 ], [ 42, 33 ], [ 46, 37 ], [ 52, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ] ]
[ "x = str(input())\nans = len(x)\nns = 0\nfor i in x:\n if i == \"S\":\n ns += 1\n elif ns > 0:\n ans -= 2\n ns -= 1\n\nprint(ans)", "x = str(input())", "x", "str(input())", "str", "input()", "input", "ans = len(x)", "ans", "len(x)", "len", "x", "ns = 0", "ns", "0", "for i in x:\n if i == \"S\":\n ns += 1\n elif ns > 0:\n ans -= 2\n ns -= 1", "i", "x", "if i == \"S\":\n ns += 1\n elif ns > 0:\n ans -= 2\n ns -= 1", "i == \"S\"", "i", "\"S\"", "ns += 1", "ns", "1", "elif ns > 0:\n ans -= 2\n ns -= 1", "ns > 0", "ns", "0", "ans -= 2", "ans", "2", "ns -= 1", "ns", "1", "print(ans)", "print", "ans", "x = str(input())", "str(input())", "x", "ns -= 1", "1", "ns", "ans -= 2", "2", "ans", "ns = 0", "0", "ns", "ans = len(x)", "len(x)", "ans", "ns += 1", "1", "ns" ]
x = str(input()) ans = len(x) ns = 0 for i in x: if i == "S": ns += 1 elif ns > 0: ans -= 2 ns -= 1 print(ans)
[ 7, 15, 15, 15, 15, 13, 15, 13, 15, 13, 4, 18, 13, 13, 17, 0, 13, 17, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 17, 13, 10, 17, 13, 10, 12, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 91, 16 ], [ 106, 39 ], [ 94, 43 ], [ 82, 46 ], [ 50, 49 ], [ 107, 54 ], [ 107, 58 ], [ 49, 59 ], [ 85, 62 ], [ 100, 67 ], [ 103, 70 ], [ 107, 77 ], [ 104, 79 ], [ 83, 79 ], [ 82, 83 ], [ 85, 86 ], [ 91, 92 ], [ 94, 95 ], [ 100, 101 ], [ 103, 104 ], [ 106, 107 ] ]
[ "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3回\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\n#import bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# pythonで無理なときは、pypyでやると正解するかも!!\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# 四捨五入g\nimport sys\nsys.setrecursionlimit(10000000)\n#mod = 10**9 + 7\n#mod = 9982443453\nmod = 998244353\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\ns = input()\nsc = 0\nans = 0\nfor i in range(len(s)):\n if s[i] == 'S':\n sc += 1\n else:\n if sc:\n sc -= 1\n ans += 1\nprint(len(s) - ans*2)", "from fractions import gcd", "from itertools import combinations,permutations,accumulate, product", "from collections import deque,defaultdict,Counter", "import decimal", "decimal", "import re", "re", "import sys", "sys", "sys.setrecursionlimit(10000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10000000", "mod = 998244353", "mod", "998244353", "def readInts():\n return list(map(int,input().split()))", "readInts", "return list(map(int,input().split()))", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def I():\n return int(input())", "I", "return int(input())", "int(input())", "int", "input()", "input", "s = input()", "s", "input()", "input", "sc = 0", "sc", "0", "ans = 0", "ans", "0", "for i in range(len(s)):\n if s[i] == 'S':\n sc += 1\n else:\n if sc:\n sc -= 1\n ans += 1", "i", "range(len(s))", "range", "len(s)", "len", "s", "if s[i] == 'S':\n sc += 1\n else:\n if sc:\n sc -= 1\n ans += 1", "s[i] == 'S'", "s[i]", "s", "i", "'S'", "sc += 1", "sc", "1", "if sc:\n sc -= 1\n ans += 1", "sc", "sc -= 1", "sc", "1", "ans += 1", "ans", "1", "print(len(s) - ans*2)", "print", "len(s) - ans*2", "len(s)", "len", "s", "ans*2", "ans", "2", "ans = 0", "0", "ans", "sc += 1", "1", "sc", "def I():\n return int(input())", "def I():\n return int(input())", "I", "mod = 998244353", "998244353", "mod", "sc = 0", "0", "sc", "def readInts():\n return list(map(int,input().split()))", "def readInts():\n return list(map(int,input().split()))", "readInts", "sc -= 1", "1", "sc", "ans += 1", "1", "ans", "s = input()", "input()", "s" ]
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate, product # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter import decimal import re #import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonで無理なときは、pypyでやると正解するかも!! # # # my_round_int = lambda x:np.round((x*2 + 1)//2) # 四捨五入g import sys sys.setrecursionlimit(10000000) #mod = 10**9 + 7 #mod = 9982443453 mod = 998244353 def readInts(): return list(map(int,input().split())) def I(): return int(input()) s = input() sc = 0 ans = 0 for i in range(len(s)): if s[i] == 'S': sc += 1 else: if sc: sc -= 1 ans += 1 print(len(s) - ans*2)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 36, 2 ], [ 51, 6 ], [ 42, 9 ], [ 13, 12 ], [ 37, 12 ], [ 12, 16 ], [ 45, 19 ], [ 48, 22 ], [ 43, 25 ], [ 49, 25 ], [ 46, 26 ], [ 52, 26 ], [ 40, 26 ], [ 39, 28 ], [ 49, 33 ], [ 43, 33 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "x = input()\ntotal = 0\nans = 0\nfor s in x:\n if s == \"T\":\n total += 1\n ans = max(ans, total)\n else:\n total -= 1\nprint(ans * 2)", "x = input()", "x", "input()", "input", "total = 0", "total", "0", "ans = 0", "ans", "0", "for s in x:\n if s == \"T\":\n total += 1\n ans = max(ans, total)\n else:\n total -= 1", "s", "x", "if s == \"T\":\n total += 1\n ans = max(ans, total)\n else:\n total -= 1", "s == \"T\"", "s", "\"T\"", "total += 1", "total", "1", "ans = max(ans, total)", "ans", "max(ans, total)", "max", "ans", "total", "total -= 1", "total", "1", "print(ans * 2)", "print", "ans * 2", "ans", "2", "x = input()", "input()", "x", "total -= 1", "1", "total", "ans = 0", "0", "ans", "total += 1", "1", "total", "ans = max(ans, total)", "max(ans, total)", "ans", "total = 0", "0", "total" ]
x = input() total = 0 ans = 0 for s in x: if s == "T": total += 1 ans = max(ans, total) else: total -= 1 print(ans * 2)
[ 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, 17, 13, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 46, 2 ], [ 37, 6 ], [ 40, 9 ], [ 47, 12 ], [ 15, 14 ], [ 47, 14 ], [ 14, 18 ], [ 49, 21 ], [ 38, 26 ], [ 53, 26 ], [ 50, 26 ], [ 52, 28 ], [ 43, 31 ], [ 44, 35 ], [ 41, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "x = input()\ncnt = 0\nans = len(x)\nfor s in x:\n if s == \"S\":\n cnt += 1\n else:\n if 0 < cnt:\n cnt -= 1\n ans -= 2\nprint(ans)", "x = input()", "x", "input()", "input", "cnt = 0", "cnt", "0", "ans = len(x)", "ans", "len(x)", "len", "x", "for s in x:\n if s == \"S\":\n cnt += 1\n else:\n if 0 < cnt:\n cnt -= 1\n ans -= 2", "s", "x", "if s == \"S\":\n cnt += 1\n else:\n if 0 < cnt:\n cnt -= 1\n ans -= 2", "s == \"S\"", "s", "\"S\"", "cnt += 1", "cnt", "1", "if 0 < cnt:\n cnt -= 1\n ans -= 2", "0 < cnt", "0", "cnt", "cnt -= 1", "cnt", "1", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "cnt = 0", "0", "cnt", "ans = len(x)", "len(x)", "ans", "ans -= 2", "2", "ans", "x = input()", "input()", "x", "cnt += 1", "1", "cnt", "cnt -= 1", "1", "cnt" ]
x = input() cnt = 0 ans = len(x) for s in x: if s == "S": cnt += 1 else: if 0 < cnt: cnt -= 1 ans -= 2 print(ans)
[ 7, 15, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 4, 18, 4, 18, 4, 13, 13, 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, 18, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13, 10, 18, 13 ]
[ [ 86, 4 ], [ 71, 13 ], [ 95, 22 ], [ 83, 31 ], [ 87, 37 ], [ 89, 41 ], [ 92, 43 ], [ 47, 46 ], [ 84, 46 ], [ 46, 50 ], [ 77, 53 ], [ 90, 57 ], [ 75, 57 ], [ 78, 57 ], [ 80, 60 ], [ 74, 63 ], [ 75, 68 ], [ 78, 68 ], [ 90, 68 ], [ 81, 69 ], [ 93, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ] ]
[ "import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nX = read().rstrip().decode()\n\ns, t = 0, 0\nfor x in X:\n if x == 'S':\n s += 1\n else:\n if s == 0:\n t += 1\n else:\n s -= 1\n\nprint(s+t)", "import sys", "sys", "read = sys.stdin.buffer.read", "read", "sys.stdin.buffer.read", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "read", "readline = sys.stdin.buffer.readline", "readline", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "readlines = sys.stdin.buffer.readlines", "readlines", "sys.stdin.buffer.readlines", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readlines", "X = read().rstrip().decode()", "X", "read().rstrip().decode()", "().rstrip().decode", "().rstrip()", "().rstrip", "()", "read", "rstrip", "decode", "s, t = 0, 0", "s", "0", "t", "0", "for x in X:\n if x == 'S':\n s += 1\n else:\n if s == 0:\n t += 1\n else:\n s -= 1", "x", "X", "if x == 'S':\n s += 1\n else:\n if s == 0:\n t += 1\n else:\n s -= 1", "x == 'S'", "x", "'S'", "s += 1", "s", "1", "if s == 0:\n t += 1\n else:\n s -= 1", "s == 0", "s", "0", "t += 1", "t", "1", "s -= 1", "s", "1", "print(s+t)", "print", "s+t", "s", "t", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline", "s -= 1", "1", "s", "s += 1", "1", "s", "t += 1", "1", "t", "X = read().rstrip().decode()", "read().rstrip().decode()", "X", "read = sys.stdin.buffer.read", "sys.stdin.buffer.read", "read", "s, t = 0, 0", "0", "s", "t = 0, 0", "0", "t", "readlines = sys.stdin.buffer.readlines", "sys.stdin.buffer.readlines", "readlines" ]
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X = read().rstrip().decode() s, t = 0, 0 for x in X: if x == 'S': s += 1 else: if s == 0: t += 1 else: s -= 1 print(s+t)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 37, 2 ], [ 52, 6 ], [ 46, 9 ], [ 38, 12 ], [ 15, 14 ], [ 38, 14 ], [ 14, 18 ], [ 43, 21 ], [ 53, 25 ], [ 41, 25 ], [ 44, 25 ], [ 40, 28 ], [ 49, 31 ], [ 50, 35 ], [ 47, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "S = input()\nk = 0\nl = len(S)\nfor i in S:\n if i == 'S':\n k += 1\n else:\n if k > 0:\n k -= 1\n l -= 2\nprint(l)", "S = input()", "S", "input()", "input", "k = 0", "k", "0", "l = len(S)", "l", "len(S)", "len", "S", "for i in S:\n if i == 'S':\n k += 1\n else:\n if k > 0:\n k -= 1\n l -= 2", "i", "S", "if i == 'S':\n k += 1\n else:\n if k > 0:\n k -= 1\n l -= 2", "i == 'S'", "i", "'S'", "k += 1", "k", "1", "if k > 0:\n k -= 1\n l -= 2", "k > 0", "k", "0", "k -= 1", "k", "1", "l -= 2", "l", "2", "print(l)", "print", "l", "S = input()", "input()", "S", "k -= 1", "1", "k", "k += 1", "1", "k", "l = len(S)", "len(S)", "l", "l -= 2", "2", "l", "k = 0", "0", "k" ]
S = input() k = 0 l = len(S) for i in S: if i == 'S': k += 1 else: if k > 0: k -= 1 l -= 2 print(l)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 39, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 2, 2, 13, 17, 2, 4, 13, 13, 17, 4, 18, 13, 13, 17, 14, 2, 2, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 14, 2, 2, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 84, 3 ], [ 81, 7 ], [ 85, 10 ], [ 78, 12 ], [ 18, 17 ], [ 85, 17 ], [ 17, 21 ], [ 79, 25 ], [ 17, 27 ], [ 17, 31 ], [ 79, 36 ], [ 79, 40 ], [ 17, 46 ], [ 79, 50 ], [ 79, 55 ], [ 17, 60 ], [ 79, 64 ], [ 79, 69 ], [ 79, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ] ]
[ "from collections import deque\n\nX = input()\nn = len(X) # even\n\nstack = deque([])\n\nfor char in X:\n\tif char == 'S':\n\t\tstack.append(char)\n\telif char == 'T' and len(stack) == 0:\n\t\tstack.append('T')\n\telif char == 'T' and stack[-1] == 'S':\n\t\tstack.pop()\n\telif char == 'T' and stack[-1] == 'T':\n\t\tstack.append('T')\n\nprint(len(stack))", "from collections import deque", "X = input()", "X", "input()", "input", "n = len(X)", "n", "len(X)", "len", "X", "stack = deque([])", "stack", "deque([])", "deque", "[]", "for char in X:\n\tif char == 'S':\n\t\tstack.append(char)\n\telif char == 'T' and len(stack) == 0:\n\t\tstack.append('T')\n\telif char == 'T' and stack[-1] == 'S':\n\t\tstack.pop()\n\telif char == 'T' and stack[-1] == 'T':\n\t\tstack.append('T')", "char", "X", "if char == 'S':\n\t\tstack.append(char)\n\telif char == 'T' and len(stack) == 0:\n\t\tstack.append('T')\n\telif char == 'T' and stack[-1] == 'S':\n\t\tstack.pop()\n\telif char == 'T' and stack[-1] == 'T':\n\t\tstack.append('T')", "char == 'S'", "char", "'S'", "stack.append(char)", "stack.append", "stack", "append", "char", "elif char == 'T' and len(stack) == 0:\n\t\tstack.append('T')\n\t", "char == 'T' and len(stack) == 0", "char == 'T'", "char", "'T'", "len(stack) == 0", "len(stack)", "len", "stack", "0", "stack.append('T')", "stack.append", "stack", "append", "'T'", "elif char == 'T' and stack[-1] == 'S':\n\t\tstack.pop()\n\t", "char == 'T' and stack[-1] == 'S'", "char == 'T'", "char", "'T'", "stack[-1] == 'S'", "stack[-1]", "stack", "-1", "'S'", "stack.pop()", "stack.pop", "stack", "pop", "elif char == 'T' and stack[-1] == 'T':\n\t\tstack.append('T')", "char == 'T' and stack[-1] == 'T'", "char == 'T'", "char", "'T'", "stack[-1] == 'T'", "stack[-1]", "stack", "-1", "'T'", "stack.append('T')", "stack.append", "stack", "append", "'T'", "print(len(stack))", "print", "len(stack)", "len", "stack", "stack = deque([])", "deque([])", "stack", "n = len(X)", "len(X)", "n", "X = input()", "input()", "X" ]
from collections import deque X = input() n = len(X) # even stack = deque([]) for char in X: if char == 'S': stack.append(char) elif char == 'T' and len(stack) == 0: stack.append('T') elif char == 'T' and stack[-1] == 'S': stack.pop() elif char == 'T' and stack[-1] == 'T': stack.append('T') print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 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, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 47, 2 ], [ 53, 6 ], [ 48, 9 ], [ 41, 11 ], [ 15, 14 ], [ 54, 17 ], [ 48, 21 ], [ 14, 22 ], [ 56, 25 ], [ 42, 29 ], [ 51, 29 ], [ 57, 29 ], [ 50, 32 ], [ 44, 35 ], [ 45, 39 ], [ 54, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ] ]
[ "S = input()\n\nans = len(S)\ns = 0\nfor i in range(ans):\n if S[i] == \"S\":\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2\n\nprint(ans)", "S = input()", "S", "input()", "input", "ans = len(S)", "ans", "len(S)", "len", "S", "s = 0", "s", "0", "for i in range(ans):\n if S[i] == \"S\":\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2", "i", "range(ans)", "range", "ans", "if S[i] == \"S\":\n s += 1\n else:\n if s > 0:\n s -= 1\n ans -= 2", "S[i] == \"S\"", "S[i]", "S", "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 = 0", "0", "s", "ans -= 2", "2", "ans", "S = input()", "input()", "S", "s -= 1", "1", "s", "ans = len(S)", "len(S)", "ans", "s += 1", "1", "s" ]
S = input() ans = len(S) s = 0 for i in range(ans): if S[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, 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, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 49, 2 ], [ 46, 6 ], [ 55, 9 ], [ 13, 12 ], [ 50, 17 ], [ 50, 21 ], [ 12, 22 ], [ 58, 25 ], [ 47, 29 ], [ 44, 29 ], [ 59, 29 ], [ 43, 32 ], [ 52, 35 ], [ 44, 40 ], [ 59, 40 ], [ 47, 40 ], [ 53, 41 ], [ 56, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "X = input()\n\nS_cnt = 0\nT_cnt = 0\nfor i in range(len(X)):\n if X[i] == 'S':\n S_cnt += 1\n else:\n if S_cnt > 0:\n S_cnt -= 1\n else:\n T_cnt += 1\n\nprint(S_cnt+T_cnt)", "X = input()", "X", "input()", "input", "S_cnt = 0", "S_cnt", "0", "T_cnt = 0", "T_cnt", "0", "for i in range(len(X)):\n if X[i] == 'S':\n S_cnt += 1\n else:\n if S_cnt > 0:\n S_cnt -= 1\n else:\n T_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 S_cnt -= 1\n else:\n T_cnt += 1", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "S_cnt += 1", "S_cnt", "1", "if S_cnt > 0:\n S_cnt -= 1\n else:\n T_cnt += 1", "S_cnt > 0", "S_cnt", "0", "S_cnt -= 1", "S_cnt", "1", "T_cnt += 1", "T_cnt", "1", "print(S_cnt+T_cnt)", "print", "S_cnt+T_cnt", "S_cnt", "T_cnt", "S_cnt -= 1", "1", "S_cnt", "S_cnt = 0", "0", "S_cnt", "X = input()", "input()", "X", "T_cnt += 1", "1", "T_cnt", "T_cnt = 0", "0", "T_cnt", "S_cnt += 1", "1", "S_cnt" ]
X = input() S_cnt = 0 T_cnt = 0 for i in range(len(X)): if X[i] == 'S': S_cnt += 1 else: if S_cnt > 0: S_cnt -= 1 else: T_cnt += 1 print(S_cnt+T_cnt)
[ 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, 4, 13, 13, 2, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 47, 2 ], [ 50, 6 ], [ 59, 9 ], [ 13, 12 ], [ 48, 17 ], [ 48, 21 ], [ 12, 22 ], [ 53, 25 ], [ 51, 29 ], [ 57, 29 ], [ 54, 29 ], [ 56, 32 ], [ 62, 35 ], [ 48, 42 ], [ 63, 45 ], [ 60, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ] ]
[ "X = input()\n\ns = 0\ncnt = 0\nfor i in range(len(X)):\n if X[i] == \"S\":\n s += 1\n elif s > 0:\n s -= 1\n cnt += 1\n\nprint(len(X)-2*cnt)", "X = input()", "X", "input()", "input", "s = 0", "s", "0", "cnt = 0", "cnt", "0", "for i in range(len(X)):\n if X[i] == \"S\":\n s += 1\n elif s > 0:\n s -= 1\n cnt += 1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i] == \"S\":\n s += 1\n elif s > 0:\n s -= 1\n cnt += 1", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "s += 1", "s", "1", "elif s > 0:\n s -= 1\n cnt += 1", "s > 0", "s", "0", "s -= 1", "s", "1", "cnt += 1", "cnt", "1", "print(len(X)-2*cnt)", "print", "len(X)-2*cnt", "len(X)", "len", "X", "2*cnt", "2", "cnt", "X = input()", "input()", "X", "s = 0", "0", "s", "s += 1", "1", "s", "s -= 1", "1", "s", "cnt = 0", "0", "cnt", "cnt += 1", "1", "cnt" ]
X = input() s = 0 cnt = 0 for i in range(len(X)): if X[i] == "S": s += 1 elif s > 0: s -= 1 cnt += 1 print(len(X)-2*cnt)
[ 7, 12, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 13, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 14, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 9, 8 ], [ 12, 11 ], [ 4, 14 ], [ 17, 16 ], [ 4, 16 ], [ 16, 20 ], [ 24, 23 ], [ 16, 27 ], [ 33, 32 ], [ 36, 35 ], [ 39, 38 ], [ 35, 42 ], [ 11, 42 ], [ 51, 48 ] ]
[ "def main():\n S = input()\n cnt = 0\n ans = len(S)\n for s in S:\n if s == 'S':\n cnt += 1\n elif s == 'T':\n if cnt:\n cnt -= 1\n ans -= 2\n else:\n cnt = 0\n \n print(ans)\n\nif __name__ == '__main__':\n main()", "def main():\n S = input()\n cnt = 0\n ans = len(S)\n for s in S:\n if s == 'S':\n cnt += 1\n elif s == 'T':\n if cnt:\n cnt -= 1\n ans -= 2\n else:\n cnt = 0\n \n print(ans)", "main", "S = input()", "S", "input()", "input", "cnt = 0", "cnt", "0", "ans = len(S)", "ans", "len(S)", "len", "S", "for s in S:\n if s == 'S':\n cnt += 1\n elif s == 'T':\n if cnt:\n cnt -= 1\n ans -= 2\n else:\n cnt = 0\n \n ", "s", "S", "if s == 'S':\n cnt += 1\n elif s == 'T':\n if cnt:\n cnt -= 1\n ans -= 2\n else:\n cnt = 0\n \n ", "s == 'S'", "s", "'S'", "cnt += 1", "cnt", "1", "elif s == 'T':\n if cnt:\n cnt -= 1\n ans -= 2\n ", "s == 'T'", "s", "'T'", "if cnt:\n cnt -= 1\n ans -= 2\n ", "cnt", "cnt -= 1", "cnt", "1", "ans -= 2", "ans", "2", "cnt = 0", "cnt", "0", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n S = input()\n cnt = 0\n ans = len(S)\n for s in S:\n if s == 'S':\n cnt += 1\n elif s == 'T':\n if cnt:\n cnt -= 1\n ans -= 2\n else:\n cnt = 0\n \n print(ans)", "def main():\n S = input()\n cnt = 0\n ans = len(S)\n for s in S:\n if s == 'S':\n cnt += 1\n elif s == 'T':\n if cnt:\n cnt -= 1\n ans -= 2\n else:\n cnt = 0\n \n print(ans)", "main" ]
def main(): S = input() cnt = 0 ans = len(S) for s in S: if s == 'S': cnt += 1 elif s == 'T': if cnt: cnt -= 1 ans -= 2 else: cnt = 0 print(ans) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 0, 13, 39, 28, 13, 13, 14, 2, 13, 17, 14, 2, 4, 13, 13, 17, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13 ]
[ [ 55, 2 ], [ 52, 6 ], [ 10, 9 ], [ 56, 9 ], [ 9, 13 ], [ 53, 19 ], [ 53, 24 ], [ 53, 29 ], [ 53, 33 ], [ 9, 35 ], [ 53, 38 ], [ 9, 40 ], [ 53, 43 ], [ 9, 45 ], [ 53, 50 ], [ 52, 53 ], [ 55, 56 ] ]
[ "x = input()\nstack = []\nfor xx in x:\n if xx == \"T\":\n if len(stack) > 0:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(xx)\n else:\n stack.append(xx)\n else:\n stack.append(xx)\n\nprint(len(stack))\n", "x = input()", "x", "input()", "input", "stack = []", "stack", "[]", "for xx in x:\n if xx == \"T\":\n if len(stack) > 0:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(xx)\n else:\n stack.append(xx)\n else:\n stack.append(xx)", "xx", "x", "if xx == \"T\":\n if len(stack) > 0:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(xx)\n else:\n stack.append(xx)\n else:\n stack.append(xx)", "xx == \"T\"", "xx", "\"T\"", "if len(stack) > 0:\n if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(xx)\n else:\n stack.append(xx)\n ", "len(stack) > 0", "len(stack)", "len", "stack", "0", "if stack[-1] == \"S\":\n stack.pop()\n else:\n stack.append(xx)\n ", "stack[-1] == \"S\"", "stack[-1]", "stack", "-1", "\"S\"", "stack.pop()", "stack.pop", "stack", "pop", "stack.append(xx)", "stack.append", "stack", "append", "xx", "stack.append(xx)", "stack.append", "stack", "append", "xx", "stack.append(xx)", "stack.append", "stack", "append", "xx", "print(len(stack))", "print", "len(stack)", "len", "stack", "stack = []", "[]", "stack", "x = input()", "input()", "x" ]
x = input() stack = [] for xx in x: if xx == "T": if len(stack) > 0: if stack[-1] == "S": stack.pop() else: stack.append(xx) else: stack.append(xx) else: stack.append(xx) print(len(stack))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 2, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 4, 13, 13, 2, 13, 17, 42, 2, 2, 13, 13, 40, 18, 13, 13, 17, 0, 13, 17, 14, 40, 13, 13, 3, 14, 2, 18, 13, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 96, 2 ], [ 78, 6 ], [ 97, 9 ], [ 90, 11 ], [ 81, 14 ], [ 18, 17 ], [ 79, 21 ], [ 97, 26 ], [ 17, 27 ], [ 75, 30 ], [ 91, 33 ], [ 94, 33 ], [ 85, 33 ], [ 76, 33 ], [ 17, 35 ], [ 76, 40 ], [ 91, 40 ], [ 85, 40 ], [ 94, 40 ], [ 79, 41 ], [ 97, 44 ], [ 76, 45 ], [ 91, 45 ], [ 85, 45 ], [ 94, 45 ], [ 84, 48 ], [ 85, 52 ], [ 76, 52 ], [ 91, 52 ], [ 94, 52 ], [ 79, 53 ], [ 97, 58 ], [ 85, 59 ], [ 76, 59 ], [ 91, 59 ], [ 94, 59 ], [ 93, 62 ], [ 87, 65 ], [ 79, 70 ], [ 88, 72 ], [ 82, 72 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ], [ 93, 94 ], [ 96, 97 ] ]
[ "X = input()\nN = len(X)\n\nright = 1\ncnt = 0\n\nfor left in range(N - 1):\n if X[left] == 'S':\n right = max(right, left + 1)\n while right < N and X[right] != 'T':\n right += 1\n if right >= N:\n break\n if X[right] == 'T':\n # print(left, right)\n right += 1\n cnt += 1\nprint(N - cnt * 2)", "X = input()", "X", "input()", "input", "N = len(X)", "N", "len(X)", "len", "X", "right = 1", "right", "1", "cnt = 0", "cnt", "0", "for left in range(N - 1):\n if X[left] == 'S':\n right = max(right, left + 1)\n while right < N and X[right] != 'T':\n right += 1\n if right >= N:\n break\n if X[right] == 'T':\n # print(left, right)\n right += 1\n cnt += 1", "left", "range(N - 1)", "range", "N - 1", "N", "1", "if X[left] == 'S':\n right = max(right, left + 1)\n while right < N and X[right] != 'T':\n right += 1\n if right >= N:\n break\n if X[right] == 'T':\n # print(left, right)\n right += 1\n cnt += 1", "X[left] == 'S'", "X[left]", "X", "left", "'S'", "right = max(right, left + 1)", "right", "max(right, left + 1)", "max", "right", "left + 1", "left", "1", "while right < N and X[right] != 'T':\n right += 1\n ", "right < N and X[right] != 'T'", "right < N", "right", "N", "X[right] != 'T'", "X[right]", "X", "right", "'T'", "right += 1", "right", "1", "if right >= N:\n break\n ", "right >= N", "right", "N", "break", "if X[right] == 'T':\n # print(left, right)\n right += 1\n cnt += 1", "X[right] == 'T'", "X[right]", "X", "right", "'T'", "right += 1", "right", "1", "cnt += 1", "cnt", "1", "print(N - cnt * 2)", "print", "N - cnt * 2", "N", "cnt * 2", "cnt", "2", "right = max(right, left + 1)", "max(right, left + 1)", "right", "N = len(X)", "len(X)", "N", "cnt = 0", "0", "cnt", "right += 1", "1", "right", "cnt += 1", "1", "cnt", "right = 1", "1", "right", "right += 1", "1", "right", "X = input()", "input()", "X" ]
X = input() N = len(X) right = 1 cnt = 0 for left in range(N - 1): if X[left] == 'S': right = max(right, left + 1) while right < N and X[right] != 'T': right += 1 if right >= N: break if X[right] == 'T': # print(left, right) right += 1 cnt += 1 print(N - cnt * 2)
[ 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, 14, 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 if d[-1] == \"S\":\n d.pop()\n else:\n 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 if d[-1] == \"S\":\n d.pop()\n else:\n 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 if d[-1] == \"S\":\n d.pop()\n else:\n 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 if d[-1] == \"S\":\n d.pop()\n else:\n d.append(s)\n ", "s == \"T\"", "s", "\"T\"", "if d[-1] == \"S\":\n d.pop()\n else:\n d.append(s)\n ", "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": if d[-1] == "S": d.pop() else: d.append(s) elif s == "S": d.append(s) print(len(d))
[ 7, 0, 13, 4, 13, 0, 13, 17, 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 ]
[ [ 43, 2 ], [ 49, 6 ], [ 52, 8 ], [ 12, 11 ], [ 44, 11 ], [ 11, 15 ], [ 55, 18 ], [ 11, 22 ], [ 50, 26 ], [ 47, 26 ], [ 56, 26 ], [ 46, 29 ], [ 40, 32 ], [ 47, 37 ], [ 56, 37 ], [ 50, 37 ], [ 41, 38 ], [ 53, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ] ]
[ "x = input()\n\ns, t = 0, 0\nfor i in x:\n if i == 'S':\n s += 1\n elif i == 'T':\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 i in x:\n if i == 'S':\n s += 1\n elif i == 'T':\n if s > 0:\n s -= 1\n else:\n t += 1", "i", "x", "if i == 'S':\n s += 1\n elif i == 'T':\n if s > 0:\n s -= 1\n else:\n t += 1", "i == 'S'", "i", "'S'", "s += 1", "s", "1", "elif i == 'T':\n if s > 0:\n s -= 1\n else:\n t += 1", "i == 'T'", "i", "'T'", "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", "t += 1", "1", "t", "x = input()", "input()", "x", "s -= 1", "1", "s", "s, t = 0, 0", "0", "s", "t = 0, 0", "0", "t", "s += 1", "1", "s" ]
x = input() s, t = 0, 0 for i in x: if i == 'S': s += 1 elif i == 'T': if s > 0: s -= 1 else: t += 1 print(s + t)
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 12, 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, 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, 18, 13 ]
[ [ 67, 4 ], [ 14, 13 ], [ 68, 17 ], [ 21, 20 ], [ 24, 23 ], [ 27, 26 ], [ 13, 26 ], [ 26, 30 ], [ 34, 33 ], [ 26, 37 ], [ 41, 40 ], [ 40, 44 ], [ 33, 44 ], [ 20, 44 ], [ 50, 44 ], [ 48, 47 ], [ 51, 50 ], [ 47, 55 ], [ 23, 55 ], [ 50, 56 ], [ 40, 56 ], [ 33, 56 ], [ 20, 56 ], [ 65, 62 ], [ 67, 68 ] ]
[ "import sys\ninput = sys.stdin.readline\n\n\ndef main():\n S = input().rstrip()\n count = 0\n ans = 0\n for s in S:\n if s == \"S\":\n count += 1\n if s == \"T\":\n count -= 1\n if count < 0:\n ans += 1\n count = 0\n\n print(ans+count)\n\n\nif __name__ == \"__main__\":\n main()", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def main():\n S = input().rstrip()\n count = 0\n ans = 0\n for s in S:\n if s == \"S\":\n count += 1\n if s == \"T\":\n count -= 1\n if count < 0:\n ans += 1\n count = 0\n\n print(ans+count)", "main", "S = input().rstrip()", "S", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "count = 0", "count", "0", "ans = 0", "ans", "0", "for s in S:\n if s == \"S\":\n count += 1\n if s == \"T\":\n count -= 1\n if count < 0:\n ans += 1\n count = 0\n\n ", "s", "S", "if s == \"S\":\n count += 1\n ", "s == \"S\"", "s", "\"S\"", "count += 1", "count", "1", "if s == \"T\":\n count -= 1\n ", "s == \"T\"", "s", "\"T\"", "count -= 1", "count", "1", "if count < 0:\n ans += 1\n count = 0\n\n ", "count < 0", "count", "0", "ans += 1", "ans", "1", "count = 0", "count", "0", "print(ans+count)", "print", "ans+count", "ans", "count", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def main():\n S = input().rstrip()\n count = 0\n ans = 0\n for s in S:\n if s == \"S\":\n count += 1\n if s == \"T\":\n count -= 1\n if count < 0:\n ans += 1\n count = 0\n\n print(ans+count)", "def main():\n S = input().rstrip()\n count = 0\n ans = 0\n for s in S:\n if s == \"S\":\n count += 1\n if s == \"T\":\n count -= 1\n if count < 0:\n ans += 1\n count = 0\n\n print(ans+count)", "main", "input = sys.stdin.readline", "sys.stdin.readline", "input" ]
import sys input = sys.stdin.readline def main(): S = input().rstrip() count = 0 ans = 0 for s in S: if s == "S": count += 1 if s == "T": count -= 1 if count < 0: ans += 1 count = 0 print(ans+count) if __name__ == "__main__": main()
[ 7, 12, 13, 0, 13, 17, 0, 13, 4, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 2, 13, 17, 29, 13, 4, 13, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 8, 7 ], [ 12, 11 ], [ 15, 14 ], [ 7, 14 ], [ 14, 18 ], [ 22, 21 ], [ 11, 25 ], [ 28, 25 ], [ 21, 25 ], [ 29, 28 ], [ 32, 31 ], [ 28, 33 ], [ 21, 33 ], [ 11, 33 ], [ 31, 36 ], [ 4, 36 ], [ 43, 40 ] ]
[ "def solve():\n ans = 0\n X = input()\n num = 0\n for x in X:\n if x=='S':\n num += 1\n else:\n if num>0:\n num -= 1\n ans = num*2\n return ans\nprint(solve())", "def solve():\n ans = 0\n X = input()\n num = 0\n for x in X:\n if x=='S':\n num += 1\n else:\n if num>0:\n num -= 1\n ans = num*2\n return ans", "solve", "ans = 0", "ans", "0", "X = input()", "X", "input()", "input", "num = 0", "num", "0", "for x in X:\n if x=='S':\n num += 1\n else:\n if num>0:\n num -= 1\n ", "x", "X", "if x=='S':\n num += 1\n else:\n if num>0:\n num -= 1\n ", "x=='S'", "x", "'S'", "num += 1", "num", "1", "if num>0:\n num -= 1\n ", "num>0", "num", "0", "num -= 1", "num", "1", "ans = num*2", "ans", "num*2", "num", "2", "return ans", "ans", "print(solve())", "print", "solve()", "solve", "def solve():\n ans = 0\n X = input()\n num = 0\n for x in X:\n if x=='S':\n num += 1\n else:\n if num>0:\n num -= 1\n ans = num*2\n return ans", "def solve():\n ans = 0\n X = input()\n num = 0\n for x in X:\n if x=='S':\n num += 1\n else:\n if num>0:\n num -= 1\n ans = num*2\n return ans", "solve" ]
def solve(): ans = 0 X = input() num = 0 for x in X: if x=='S': num += 1 else: if num>0: num -= 1 ans = num*2 return ans print(solve())
[ 7, 15, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 15, 4, 18, 13, 13, 2, 17, 17, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 39, 17, 17, 17, 17, 0, 13, 39, 17, 17, 17, 17, 41, 28, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 4, 13, 13, 12, 13, 41, 28, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 2, 4, 13, 13, 17, 12, 13, 41, 28, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 4, 13, 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, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 13, 4, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13, 10, 39, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 39, 13, 10, 2, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 163, 25 ], [ 187, 30 ], [ 169, 37 ], [ 184, 44 ], [ 53, 52 ], [ 52, 65 ], [ 71, 70 ], [ 70, 84 ], [ 91, 90 ], [ 90, 103 ], [ 118, 117 ], [ 179, 119 ], [ 122, 121 ], [ 125, 124 ], [ 128, 127 ], [ 117, 127 ], [ 127, 131 ], [ 135, 134 ], [ 127, 138 ], [ 134, 142 ], [ 121, 142 ], [ 145, 142 ], [ 146, 145 ], [ 149, 148 ], [ 117, 155 ], [ 148, 156 ], [ 124, 156 ], [ 173, 158 ], [ 163, 164 ], [ 169, 170 ], [ 184, 185 ], [ 187, 188 ] ]
[ "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\nfrom collections import deque\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nDR = [1, -1, 0, 0]\nDC = [0, 0, 1, -1]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n \ndef main():\n x = S()\n s_cnt = 0\n removed = 0\n for c in x:\n if c == 'S':\n s_cnt += 1\n if c == 'T':\n if s_cnt > 0:\n s_cnt -= 1\n removed += 2\n print(len(x) - removed)\nmain()\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools", "math", "string", "itertools", "fractions", "heapq", "collections", "re", "array", "bisect", "sys", "random", "time", "copy", "functools", "from collections import deque", "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", "DR = [1, -1, 0, 0]", "DR", "[1, -1, 0, 0]", "1", "-1", "0", "0", "DC = [0, 0, 1, -1]", "DC", "[0, 0, 1, -1]", "0", "0", "1", "-1", "int(x) for x in sys.stdin.readline().split()", "for x in sys.stdin.readline().split()", "x", "sys.stdin.readline().split()", "sys.stdin.readline().split", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "split", "for x in sys.stdin.readline().split()", "int(x)", "int", "x", "def LI(): return [int(x) for x in sys.stdin.readline().split()]", "LI", "int(x)-1 for x in sys.stdin.readline().split()", "for x in sys.stdin.readline().split()", "x", "sys.stdin.readline().split()", "sys.stdin.readline().split", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "split", "for x in sys.stdin.readline().split()", "int(x)-1", "int(x)", "int", "x", "1", "def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]", "LI_", "float(x) for x in sys.stdin.readline().split()", "for x in sys.stdin.readline().split()", "x", "sys.stdin.readline().split()", "sys.stdin.readline().split", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "split", "for x in sys.stdin.readline().split()", "float(x)", "float", "x", "def LF(): return [float(x) for x in sys.stdin.readline().split()]", "LF", "def LS(): return sys.stdin.readline().split()", "LS", "def I(): return int(sys.stdin.readline())", "I", "def F(): return float(sys.stdin.readline())", "F", "def S(): return input()\n ", "S", "def main():\n x = S()\n s_cnt = 0\n removed = 0\n for c in x:\n if c == 'S':\n s_cnt += 1\n if c == 'T':\n if s_cnt > 0:\n s_cnt -= 1\n removed += 2\n print(len(x) - removed)", "main", "x = S()", "x", "S()", "S", "s_cnt = 0", "s_cnt", "0", "removed = 0", "removed", "0", "for c in x:\n if c == 'S':\n s_cnt += 1\n if c == 'T':\n if s_cnt > 0:\n s_cnt -= 1\n removed += 2\n ", "c", "x", "if c == 'S':\n s_cnt += 1\n ", "c == 'S'", "c", "'S'", "s_cnt += 1", "s_cnt", "1", "if c == 'T':\n if s_cnt > 0:\n s_cnt -= 1\n removed += 2\n ", "c == 'T'", "c", "'T'", "if s_cnt > 0:\n s_cnt -= 1\n removed += 2\n ", "s_cnt > 0", "s_cnt", "0", "s_cnt -= 1", "s_cnt", "1", "removed += 2", "removed", "2", "print(len(x) - removed)", "print", "len(x) - removed", "len(x)", "len", "x", "removed", "main()", "main", "def LF(): return [float(x) for x in sys.stdin.readline().split()]", "def LF(): return [float(x) for x in sys.stdin.readline().split()]", "LF", "inf = 10**20", "10**20", "inf", "def I(): return int(sys.stdin.readline())", "def I(): return int(sys.stdin.readline())", "I", "DR = [1, -1, 0, 0]", "[1, -1, 0, 0]", "DR", "def main():\n x = S()\n s_cnt = 0\n removed = 0\n for c in x:\n if c == 'S':\n s_cnt += 1\n if c == 'T':\n if s_cnt > 0:\n s_cnt -= 1\n removed += 2\n print(len(x) - removed)", "def main():\n x = S()\n s_cnt = 0\n removed = 0\n for c in x:\n if c == 'S':\n s_cnt += 1\n if c == 'T':\n if s_cnt > 0:\n s_cnt -= 1\n removed += 2\n print(len(x) - removed)", "main", "def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]", "def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]", "LI_", "def S(): return input()\n ", "def S(): return input()\n ", "S", "def LI(): return [int(x) for x in sys.stdin.readline().split()]", "def LI(): return [int(x) for x in sys.stdin.readline().split()]", "LI", "DC = [0, 0, 1, -1]", "[0, 0, 1, -1]", "DC", "mod = 10**9 + 7", "10**9 + 7", "mod", "def LS(): return sys.stdin.readline().split()", "def LS(): return sys.stdin.readline().split()", "LS", "def F(): return float(sys.stdin.readline())", "def F(): return float(sys.stdin.readline())", "F" ]
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools from collections import deque sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 DR = [1, -1, 0, 0] DC = [0, 0, 1, -1] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def main(): x = S() s_cnt = 0 removed = 0 for c in x: if c == 'S': s_cnt += 1 if c == 'T': if s_cnt > 0: s_cnt -= 1 removed += 2 print(len(x) - removed) main()
[ 7, 0, 13, 4, 13, 0, 13, 17, 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, 4, 13, 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 67, 2 ], [ 70, 6 ], [ 73, 8 ], [ 61, 11 ], [ 52, 14 ], [ 18, 17 ], [ 68, 17 ], [ 17, 21 ], [ 76, 24 ], [ 71, 28 ], [ 59, 28 ], [ 65, 28 ], [ 77, 28 ], [ 55, 31 ], [ 64, 34 ], [ 58, 37 ], [ 65, 40 ], [ 71, 40 ], [ 59, 40 ], [ 77, 40 ], [ 68, 47 ], [ 56, 49 ], [ 53, 49 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "x = input()\n\ns, t = 0, 0\nols = 0\ncnt = 0\nfor i in x:\n if i == \"S\":\n s += 1\n else:\n if s > 0:\n cnt += 1\n s -= 1\n s = max(s,0)\nprint (len(x)-cnt*2)", "x = input()", "x", "input()", "input", "s, t = 0, 0", "s", "0", "t", "0", "ols = 0", "ols", "0", "cnt = 0", "cnt", "0", "for i in x:\n if i == \"S\":\n s += 1\n else:\n if s > 0:\n cnt += 1\n s -= 1\n s = max(s,0)", "i", "x", "if i == \"S\":\n s += 1\n else:\n if s > 0:\n cnt += 1\n s -= 1\n s = max(s,0)", "i == \"S\"", "i", "\"S\"", "s += 1", "s", "1", "if s > 0:\n cnt += 1\n s -= 1\n s = max(s,0)", "s > 0", "s", "0", "cnt += 1", "cnt", "1", "s -= 1", "s", "1", "s = max(s,0)", "s", "max(s,0)", "max", "s", "0", "print (len(x)-cnt*2)", "print", "len(x)-cnt*2", "len(x)", "len", "x", "cnt*2", "cnt", "2", "cnt = 0", "0", "cnt", "cnt += 1", "1", "cnt", "s = max(s,0)", "max(s,0)", "s", "ols = 0", "0", "ols", "s -= 1", "1", "s", "x = input()", "input()", "x", "s, t = 0, 0", "0", "s", "t = 0, 0", "0", "t", "s += 1", "1", "s" ]
x = input() s, t = 0, 0 ols = 0 cnt = 0 for i in x: if i == "S": s += 1 else: if s > 0: cnt += 1 s -= 1 s = max(s,0) print (len(x)-cnt*2)
[ 7, 12, 13, 15, 13, 0, 13, 18, 18, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 39, 4, 13, 12, 13, 12, 13, 12, 13, 23, 13, 12, 13, 23, 13, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 18, 13, 13, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 7, 6 ], [ 35, 34 ], [ 6, 42 ], [ 48, 47 ], [ 31, 54 ], [ 62, 62 ], [ 66, 66 ], [ 69, 68 ], [ 74, 73 ], [ 81, 80 ], [ 58, 82 ], [ 85, 84 ], [ 80, 87 ], [ 90, 89 ], [ 84, 90 ], [ 93, 92 ], [ 96, 95 ], [ 84, 98 ], [ 80, 103 ], [ 95, 104 ], [ 92, 107 ], [ 122, 107 ], [ 110, 107 ], [ 111, 110 ], [ 114, 113 ], [ 80, 118 ], [ 95, 119 ], [ 123, 122 ], [ 113, 126 ], [ 89, 126 ], [ 135, 132 ] ]
[ "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from collections import defaultdict\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 from math import floor, ceil,pi,factorial\n from operator import itemgetter\n def I(): return int(input())\n def MI(): return map(int, input().split())\n def LI(): return list(map(int, input().split()))\n def LI2(): return [int(input()) for i in range(n)]\n def MXI(): return [[LI()]for i in range(n)]\n def SI(): return input().rstrip()\n def printns(x): print('\\n'.join(x))\n def printni(x): print('\\n'.join(list(map(str,x))))\n inf = 10**17\n mod = 10**9 + 7\n#main code here!\n s=SI()\n n=len(s)\n ans=n\n pool=0\n for i in range(n):\n if s[i]==\"T\" and pool>0:\n pool-=1\n ans-=2\n if s[i]==\"S\":\n pool+=1\n print(ans)\n \n\n \n \n \n \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 collections import defaultdict\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 from math import floor, ceil,pi,factorial\n from operator import itemgetter\n def I(): return int(input())\n def MI(): return map(int, input().split())\n def LI(): return list(map(int, input().split()))\n def LI2(): return [int(input()) for i in range(n)]\n def MXI(): return [[LI()]for i in range(n)]\n def SI(): return input().rstrip()\n def printns(x): print('\\n'.join(x))\n def printni(x): print('\\n'.join(list(map(str,x))))\n inf = 10**17\n mod = 10**9 + 7\n#main code here!\n s=SI()\n n=len(s)\n ans=n\n pool=0\n for i in range(n):\n if s[i]==\"T\" and pool>0:\n pool-=1\n ans-=2\n if s[i]==\"S\":\n pool+=1\n print(ans)\n \n\n \n \n \n \n ", "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 collections import defaultdict", "from itertools import combinations, permutations, accumulate, groupby, product", "from bisect import bisect_left,bisect_right", "from heapq import heapify, heappop, heappush", "from math import floor, ceil,pi,factorial", "from operator import itemgetter", "def I(): return int(input())\n ", "I", "def MI(): return map(int, input().split())\n ", "MI", "def LI(): return list(map(int, input().split()))\n ", "LI", "int(input()) for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "int(input())", "int", "input()", "input", "def LI2(): return [int(input()) for i in range(n)]\n ", "LI2", "[LI()]for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "[LI()]", "LI()", "LI", "def MXI(): return [[LI()]for i in range(n)]\n ", "MXI", "def SI(): return input().rstrip()\n ", "SI", "def printns(x): print('\\n'.join(x))\n ", "printns", "x", "x", "def printni(x): print('\\n'.join(list(map(str,x))))\n ", "printni", "x", "x", "inf = 10**17", "inf", "10**17", "10", "17", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "s=SI()", "s", "SI()", "SI", "n=len(s)", "n", "len(s)", "len", "s", "ans=n", "ans", "n", "pool=0", "pool", "0", "for i in range(n):\n if s[i]==\"T\" and pool>0:\n pool-=1\n ans-=2\n if s[i]==\"S\":\n pool+=1\n ", "i", "range(n)", "range", "n", "if s[i]==\"T\" and pool>0:\n pool-=1\n ans-=2\n ", "s[i]==\"T\" and pool>0", "s[i]==\"T\"", "s[i]", "s", "i", "\"T\"", "pool>0", "pool", "0", "pool-=1", "pool", "1", "ans-=2", "ans", "2", "if s[i]==\"S\":\n pool+=1\n ", "s[i]==\"S\"", "s[i]", "s", "i", "\"S\"", "pool+=1", "pool", "1", "print(ans)", "print", "ans", "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 collections import defaultdict\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 from math import floor, ceil,pi,factorial\n from operator import itemgetter\n def I(): return int(input())\n def MI(): return map(int, input().split())\n def LI(): return list(map(int, input().split()))\n def LI2(): return [int(input()) for i in range(n)]\n def MXI(): return [[LI()]for i in range(n)]\n def SI(): return input().rstrip()\n def printns(x): print('\\n'.join(x))\n def printni(x): print('\\n'.join(list(map(str,x))))\n inf = 10**17\n mod = 10**9 + 7\n#main code here!\n s=SI()\n n=len(s)\n ans=n\n pool=0\n for i in range(n):\n if s[i]==\"T\" and pool>0:\n pool-=1\n ans-=2\n if s[i]==\"S\":\n pool+=1\n print(ans)\n \n\n \n \n \n \n ", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from collections import defaultdict\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 from math import floor, ceil,pi,factorial\n from operator import itemgetter\n def I(): return int(input())\n def MI(): return map(int, input().split())\n def LI(): return list(map(int, input().split()))\n def LI2(): return [int(input()) for i in range(n)]\n def MXI(): return [[LI()]for i in range(n)]\n def SI(): return input().rstrip()\n def printns(x): print('\\n'.join(x))\n def printni(x): print('\\n'.join(list(map(str,x))))\n inf = 10**17\n mod = 10**9 + 7\n#main code here!\n s=SI()\n n=len(s)\n ans=n\n pool=0\n for i in range(n):\n if s[i]==\"T\" and pool>0:\n pool-=1\n ans-=2\n if s[i]==\"S\":\n pool+=1\n print(ans)\n \n\n \n \n \n \n ", "main" ]
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LI2(): return [int(input()) for i in range(n)] def MXI(): return [[LI()]for i in range(n)] def SI(): return input().rstrip() def printns(x): print('\n'.join(x)) def printni(x): print('\n'.join(list(map(str,x)))) inf = 10**17 mod = 10**9 + 7 #main code here! s=SI() n=len(s) ans=n pool=0 for i in range(n): if s[i]=="T" and pool>0: pool-=1 ans-=2 if s[i]=="S": pool+=1 print(ans) if __name__=="__main__": main()
[ 7, 0, 13, 4, 18, 4, 13, 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, 0, 13, 17, 14, 2, 13, 2, 13, 17, 0, 13, 4, 13, 13, 13, 14, 2, 13, 13, 0, 13, 13, 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, 4, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 80, 2 ], [ 101, 9 ], [ 81, 12 ], [ 98, 14 ], [ 104, 17 ], [ 104, 20 ], [ 24, 23 ], [ 102, 26 ], [ 81, 30 ], [ 23, 31 ], [ 83, 34 ], [ 74, 37 ], [ 23, 41 ], [ 102, 43 ], [ 89, 46 ], [ 84, 49 ], [ 105, 49 ], [ 87, 49 ], [ 75, 50 ], [ 96, 50 ], [ 78, 50 ], [ 75, 53 ], [ 96, 53 ], [ 78, 53 ], [ 84, 54 ], [ 105, 54 ], [ 87, 54 ], [ 92, 56 ], [ 84, 57 ], [ 105, 57 ], [ 87, 57 ], [ 86, 59 ], [ 86, 62 ], [ 81, 69 ], [ 93, 71 ], [ 90, 71 ], [ 99, 71 ], [ 74, 75 ], [ 86, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 84, 92 ], [ 105, 92 ], [ 87, 92 ], [ 92, 93 ], [ 104, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ] ]
[ "s = input().rstrip()\nn = len(s)\n\nremoved = 0\ncnt_s = cnt_t = 0\n\nfor i in range(n):\n if s[i] == 'S':\n cnt_s += 1\n else:\n cnt_t += 1\n if i == n-1:\n removed += min(cnt_s,cnt_t)\n elif cnt_t > cnt_s:\n removed += cnt_s\n cnt_s = cnt_t = 0\n# print(cnt_s,cnt_t)\nprint(len(s) - removed*2)", "s = input().rstrip()", "s", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "n = len(s)", "n", "len(s)", "len", "s", "removed = 0", "removed", "0", "cnt_s = cnt_t = 0", "cnt_s", "0", "= cnt_t = 0", "cnt_t", "0", "for i in range(n):\n if s[i] == 'S':\n cnt_s += 1\n else:\n cnt_t += 1\n if i == n-1:\n removed += min(cnt_s,cnt_t)\n elif cnt_t > cnt_s:\n removed += cnt_s\n cnt_s = cnt_t = 0\n# print(cnt_s,cnt_t)", "i", "range(n)", "range", "n", "if s[i] == 'S':\n cnt_s += 1\n else:\n cnt_t += 1\n ", "s[i] == 'S'", "s[i]", "s", "i", "'S'", "cnt_s += 1", "cnt_s", "1", "cnt_t += 1", "cnt_t", "1", "if i == n-1:\n removed += min(cnt_s,cnt_t)\n elif cnt_t > cnt_s:\n removed += cnt_s\n cnt_s = cnt_t = 0\n# print(cnt_s,cnt_t)", "i == n-1", "i", "n-1", "n", "1", "removed += min(cnt_s,cnt_t)", "removed", "min(cnt_s,cnt_t)", "min", "cnt_s", "cnt_t", "elif cnt_t > cnt_s:\n removed += cnt_s\n cnt_s = cnt_t = 0\n# print(cnt_s,cnt_t)", "cnt_t > cnt_s", "cnt_t", "cnt_s", "removed += cnt_s", "removed", "cnt_s", "cnt_s = cnt_t = 0", "cnt_s", "0", "= cnt_t = 0", "cnt_t", "0", "print(len(s) - removed*2)", "print", "len(s) - removed*2", "len(s)", "len", "s", "removed*2", "removed", "2", "cnt_t += 1", "1", "cnt_t", "cnt_t = 0", "0", "cnt_t", "s = input().rstrip()", "input().rstrip()", "s", "cnt_s += 1", "1", "cnt_s", "cnt_s = cnt_t = 0", "0", "cnt_s", "removed += min(cnt_s,cnt_t)", "min(cnt_s,cnt_t)", "removed", "removed += cnt_s", "cnt_s", "removed", "cnt_t = 0", "0", "cnt_t", "removed = 0", "0", "removed", "n = len(s)", "len(s)", "n", "cnt_s = cnt_t = 0", "0", "cnt_s" ]
s = input().rstrip() n = len(s) removed = 0 cnt_s = cnt_t = 0 for i in range(n): if s[i] == 'S': cnt_s += 1 else: cnt_t += 1 if i == n-1: removed += min(cnt_s,cnt_t) elif cnt_t > cnt_s: removed += cnt_s cnt_s = cnt_t = 0 # print(cnt_s,cnt_t) print(len(s) - removed*2)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 13, 14, 4, 18, 13, 13, 9, 4, 18, 13, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 44, 3 ], [ 47, 7 ], [ 45, 10 ], [ 50, 12 ], [ 17, 16 ], [ 45, 16 ], [ 16, 20 ], [ 51, 24 ], [ 16, 26 ], [ 51, 30 ], [ 51, 35 ], [ 53, 38 ], [ 54, 42 ], [ 48, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ] ]
[ "from queue import Queue\n\nS = input()\nans = len(S)\nQ = Queue()\nfor s in S:\n if s == 'S':\n Q.put(s)\n else:\n if Q.empty():\n continue\n Q.get()\n ans -= 2\nprint(ans)", "from queue import Queue", "S = input()", "S", "input()", "input", "ans = len(S)", "ans", "len(S)", "len", "S", "Q = Queue()", "Q", "Queue()", "Queue", "for s in S:\n if s == 'S':\n Q.put(s)\n else:\n if Q.empty():\n continue\n Q.get()\n ans -= 2", "s", "S", "if s == 'S':\n Q.put(s)\n else:\n if Q.empty():\n continue\n Q.get()\n ans -= 2", "s == 'S'", "s", "'S'", "Q.put(s)", "Q.put", "Q", "put", "s", "if Q.empty():\n continue\n ", "Q.empty()", "Q.empty", "Q", "empty", "continue", "Q.get()", "Q.get", "Q", "get", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "S = input()", "input()", "S", "ans = len(S)", "len(S)", "ans", "Q = Queue()", "Queue()", "Q", "ans -= 2", "2", "ans" ]
from queue import Queue S = input() ans = len(S) Q = Queue() for s in S: if s == 'S': Q.put(s) else: if Q.empty(): continue Q.get() ans -= 2 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 39, 0, 13, 4, 13, 13, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 17, 14, 4, 13, 13, 4, 18, 13, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 39, 13, 10, 17, 13 ]
[ [ 49, 2 ], [ 52, 6 ], [ 46, 9 ], [ 50, 12 ], [ 15, 14 ], [ 50, 19 ], [ 50, 23 ], [ 14, 24 ], [ 53, 28 ], [ 53, 34 ], [ 53, 37 ], [ 55, 40 ], [ 56, 44 ], [ 47, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ] ]
[ "x = input()\nls = []\nans = len(x)\nfor i in range(len(x)):\n if x[i] == \"S\":\n ls.append(\"S\")\n else:\n if len(ls):\n ls.pop()\n ans -= 2\nprint(ans)", "x = input()", "x", "input()", "input", "ls = []", "ls", "[]", "ans = len(x)", "ans", "len(x)", "len", "x", "for i in range(len(x)):\n if x[i] == \"S\":\n ls.append(\"S\")\n else:\n if len(ls):\n ls.pop()\n ans -= 2", "i", "range(len(x))", "range", "len(x)", "len", "x", "if x[i] == \"S\":\n ls.append(\"S\")\n else:\n if len(ls):\n ls.pop()\n ans -= 2", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "ls.append(\"S\")", "ls.append", "ls", "append", "\"S\"", "if len(ls):\n ls.pop()\n ans -= 2", "len(ls)", "len", "ls", "ls.pop()", "ls.pop", "ls", "pop", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "ans = len(x)", "len(x)", "ans", "x = input()", "input()", "x", "ls = []", "[]", "ls", "ans -= 2", "2", "ans" ]
x = input() ls = [] ans = len(x) for i in range(len(x)): if x[i] == "S": ls.append("S") else: if len(ls): ls.pop() ans -= 2 print(ans)
[ 7, 0, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 0, 13, 17, 14, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 67, 2 ], [ 52, 9 ], [ 68, 12 ], [ 58, 14 ], [ 61, 17 ], [ 21, 20 ], [ 53, 23 ], [ 68, 27 ], [ 20, 28 ], [ 49, 31 ], [ 55, 36 ], [ 64, 39 ], [ 53, 44 ], [ 65, 46 ], [ 59, 46 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "s = input().rstrip()\nn = len(s)\n\nremoved = 0\ncnt_s = 0\n\nfor i in range(n):\n if s[i] == 'S':\n cnt_s += 1\n elif cnt_s:\n cnt_s -= 1\n removed += 1\n# print(cnt_s,cnt_t)\nprint(n - removed*2)", "s = input().rstrip()", "s", "input().rstrip()", "().rstrip", "()", "input", "rstrip", "n = len(s)", "n", "len(s)", "len", "s", "removed = 0", "removed", "0", "cnt_s = 0", "cnt_s", "0", "for i in range(n):\n if s[i] == 'S':\n cnt_s += 1\n elif cnt_s:\n cnt_s -= 1\n removed += 1\n# print(cnt_s,cnt_t)", "i", "range(n)", "range", "n", "if s[i] == 'S':\n cnt_s += 1\n elif cnt_s:\n cnt_s -= 1\n removed += 1\n# print(cnt_s,cnt_t)", "s[i] == 'S'", "s[i]", "s", "i", "'S'", "cnt_s += 1", "cnt_s", "1", "elif cnt_s:\n cnt_s -= 1\n removed += 1\n# print(cnt_s,cnt_t)", "cnt_s", "cnt_s -= 1", "cnt_s", "1", "removed += 1", "removed", "1", "print(n - removed*2)", "print", "n - removed*2", "n", "removed*2", "removed", "2", "cnt_s += 1", "1", "cnt_s", "n = len(s)", "len(s)", "n", "cnt_s -= 1", "1", "cnt_s", "removed = 0", "0", "removed", "cnt_s = 0", "0", "cnt_s", "removed += 1", "1", "removed", "s = input().rstrip()", "input().rstrip()", "s" ]
s = input().rstrip() n = len(s) removed = 0 cnt_s = 0 for i in range(n): if s[i] == 'S': cnt_s += 1 elif cnt_s: cnt_s -= 1 removed += 1 # print(cnt_s,cnt_t) print(n - removed*2)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 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, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 38, 2 ], [ 41, 6 ], [ 39, 9 ], [ 44, 11 ], [ 15, 14 ], [ 39, 14 ], [ 14, 18 ], [ 35, 21 ], [ 47, 26 ], [ 50, 29 ], [ 48, 33 ], [ 42, 33 ], [ 35, 36 ], [ 38, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ] ]
[ "X = input()\n\nans = len(X)\ns = 0\nfor x in X:\n if x == \"S\":\n s += 1\n else:\n if s:\n ans -= 2\n s -= 1\nprint(ans)", "X = input()", "X", "input()", "input", "ans = len(X)", "ans", "len(X)", "len", "X", "s = 0", "s", "0", "for x in X:\n if x == \"S\":\n s += 1\n else:\n if s:\n ans -= 2\n s -= 1", "x", "X", "if x == \"S\":\n s += 1\n else:\n if s:\n ans -= 2\n s -= 1", "x == \"S\"", "x", "\"S\"", "s += 1", "s", "1", "if s:\n ans -= 2\n s -= 1", "s", "ans -= 2", "ans", "2", "s -= 1", "s", "1", "print(ans)", "print", "ans", "s += 1", "1", "s", "X = input()", "input()", "X", "ans = len(X)", "len(X)", "ans", "s = 0", "0", "s", "ans -= 2", "2", "ans", "s -= 1", "1", "s" ]
X = input() ans = len(X) s = 0 for x in X: if x == "S": s += 1 else: if s: ans -= 2 s -= 1 print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 13, 14, 2, 18, 13, 13, 17, 0, 13, 13, 3, 0, 13, 17, 28, 13, 4, 13, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 14, 2, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 78, 2 ], [ 72, 6 ], [ 79, 9 ], [ 75, 11 ], [ 15, 14 ], [ 73, 18 ], [ 79, 22 ], [ 14, 23 ], [ 66, 26 ], [ 14, 27 ], [ 81, 30 ], [ 34, 33 ], [ 67, 36 ], [ 76, 36 ], [ 79, 39 ], [ 79, 43 ], [ 33, 44 ], [ 79, 50 ], [ 33, 51 ], [ 82, 54 ], [ 85, 54 ], [ 84, 57 ], [ 69, 60 ], [ 70, 64 ], [ 73, 64 ], [ 14, 66 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ] ]
[ "string = input()\n\nlength = len(string)\nsindex = 0\nfor i in range(0, length):\n if string[i] == \"S\": \n sindex = i\n break\n \ns_count = 0\n\nfor i in range(sindex, len(string)):\n if string[i] == \"S\": s_count += 1\n if string[i] == \"T\" and s_count > 0:\n s_count -= 1\n length -= 2\n \nprint(length)", "string = input()", "string", "input()", "input", "length = len(string)", "length", "len(string)", "len", "string", "sindex = 0", "sindex", "0", "for i in range(0, length):\n if string[i] == \"S\": \n sindex = i\n break\n ", "i", "range(0, length)", "range", "0", "length", "if string[i] == \"S\": \n sindex = i\n break\n ", "string[i] == \"S\"", "string[i]", "string", "i", "\"S\"", "sindex = i", "sindex", "i", "break", "s_count = 0", "s_count", "0", "for i in range(sindex, len(string)):\n if string[i] == \"S\": s_count += 1\n if string[i] == \"T\" and s_count > 0:\n s_count -= 1\n length -= 2\n ", "i", "range(sindex, len(string))", "range", "sindex", "len(string)", "len", "string", "if string[i] == \"S\": s_count += 1\n ", "string[i] == \"S\"", "string[i]", "string", "i", "\"S\"", "if string[i] == \"T\" and s_count > 0:\n s_count -= 1\n length -= 2\n ", "string[i] == \"T\" and s_count > 0", "string[i] == \"T\"", "string[i]", "string", "i", "\"T\"", "s_count > 0", "s_count", "0", "s_count -= 1", "s_count", "1", "length -= 2", "length", "2", "print(length)", "print", "length", "sindex = i", "i", "sindex", "length -= 2", "2", "length", "length = len(string)", "len(string)", "length", "sindex = 0", "0", "sindex", "string = input()", "input()", "string", "s_count = 0", "0", "s_count", "s_count -= 1", "1", "s_count" ]
string = input() length = len(string) sindex = 0 for i in range(0, length): if string[i] == "S": sindex = i break s_count = 0 for i in range(sindex, len(string)): if string[i] == "S": s_count += 1 if string[i] == "T" and s_count > 0: s_count -= 1 length -= 2 print(length)
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 18, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 18, 13, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 73, 3 ], [ 70, 7 ], [ 74, 11 ], [ 15, 14 ], [ 74, 20 ], [ 74, 24 ], [ 14, 25 ], [ 71, 29 ], [ 74, 32 ], [ 14, 33 ], [ 71, 38 ], [ 71, 42 ], [ 74, 45 ], [ 14, 46 ], [ 71, 50 ], [ 71, 55 ], [ 74, 58 ], [ 14, 59 ], [ 71, 62 ], [ 71, 68 ], [ 70, 71 ], [ 73, 74 ] ]
[ "from collections import deque\nx = input()\nstack = deque(x[0])\nfor i in range(1,len(x)):\n if x[i] == \"S\":\n stack.appendleft(x[i])\n else: #x[i] == \"T\"\n if len(stack) == 0:\n stack.append(x[i])\n elif stack[0] == \"T\":\n stack.appendleft(x[i])\n else:\n stack.popleft()\nprint(len(stack))", "from collections import deque", "x = input()", "x", "input()", "input", "stack = deque(x[0])", "stack", "deque(x[0])", "deque", "x[0]", "x", "0", "for i in range(1,len(x)):\n if x[i] == \"S\":\n stack.appendleft(x[i])\n else: #x[i] == \"T\"\n if len(stack) == 0:\n stack.append(x[i])\n elif stack[0] == \"T\":\n stack.appendleft(x[i])\n else:\n stack.popleft()", "i", "range(1,len(x))", "range", "1", "len(x)", "len", "x", "if x[i] == \"S\":\n stack.appendleft(x[i])\n else: #x[i] == \"T\"\n if len(stack) == 0:\n stack.append(x[i])\n elif stack[0] == \"T\":\n stack.appendleft(x[i])\n else:\n stack.popleft()", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "stack.appendleft(x[i])", "stack.appendleft", "stack", "appendleft", "x[i]", "x", "i", "if len(stack) == 0:\n stack.append(x[i])\n elif stack[0] == \"T\":\n stack.appendleft(x[i])\n else:\n stack.popleft()", "len(stack) == 0", "len(stack)", "len", "stack", "0", "stack.append(x[i])", "stack.append", "stack", "append", "x[i]", "x", "i", "elif stack[0] == \"T\":\n stack.appendleft(x[i])\n ", "stack[0] == \"T\"", "stack[0]", "stack", "0", "\"T\"", "stack.appendleft(x[i])", "stack.appendleft", "stack", "appendleft", "x[i]", "x", "i", "stack.popleft()", "stack.popleft", "stack", "popleft", "print(len(stack))", "print", "len(stack)", "len", "stack", "stack = deque(x[0])", "deque(x[0])", "stack", "x = input()", "input()", "x" ]
from collections import deque x = input() stack = deque(x[0]) for i in range(1,len(x)): if x[i] == "S": stack.appendleft(x[i]) else: #x[i] == "T" if len(stack) == 0: stack.append(x[i]) elif stack[0] == "T": stack.appendleft(x[i]) else: stack.popleft() print(len(stack))
[ 7, 15, 12, 13, 0, 13, 39, 28, 13, 4, 13, 4, 13, 13, 14, 2, 4, 13, 13, 17, 14, 2, 2, 18, 13, 2, 4, 13, 13, 17, 17, 2, 18, 13, 13, 17, 4, 18, 13, 13, 4, 18, 13, 13, 18, 13, 13, 4, 18, 13, 13, 18, 13, 13, 29, 4, 13, 13, 23, 13, 12, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 6, 5 ], [ 9, 8 ], [ 59, 13 ], [ 5, 18 ], [ 5, 24 ], [ 5, 28 ], [ 59, 33 ], [ 8, 34 ], [ 5, 38 ], [ 5, 42 ], [ 59, 45 ], [ 8, 46 ], [ 5, 49 ], [ 59, 52 ], [ 8, 53 ], [ 5, 57 ], [ 59, 59 ], [ 64, 63 ], [ 79, 69 ], [ 63, 70 ], [ 82, 76 ] ]
[ "from bisect import bisect_right\n\ndef cal(X):\n output = []\n for i in range(len(X)):\n if len(output) > 0:\n if output[len(output)-1] == \"S\" and X[i] == \"T\":\n output.pop()\n else:\n output.append(X[i])\n else:\n output.append(X[i])\n\n return len(output)\n\ndef main():\n X = input()\n print(cal(X))\n\nif __name__ == \"__main__\":\n main()", "from bisect import bisect_right", "def cal(X):\n output = []\n for i in range(len(X)):\n if len(output) > 0:\n if output[len(output)-1] == \"S\" and X[i] == \"T\":\n output.pop()\n else:\n output.append(X[i])\n else:\n output.append(X[i])\n\n return len(output)", "cal", "output = []", "output", "[]", "for i in range(len(X)):\n if len(output) > 0:\n if output[len(output)-1] == \"S\" and X[i] == \"T\":\n output.pop()\n else:\n output.append(X[i])\n else:\n output.append(X[i])\n\n ", "i", "range(len(X))", "range", "len(X)", "len", "X", "if len(output) > 0:\n if output[len(output)-1] == \"S\" and X[i] == \"T\":\n output.pop()\n else:\n output.append(X[i])\n else:\n output.append(X[i])\n\n ", "len(output) > 0", "len(output)", "len", "output", "0", "if output[len(output)-1] == \"S\" and X[i] == \"T\":\n output.pop()\n else:\n output.append(X[i])\n ", "output[len(output)-1] == \"S\" and X[i] == \"T\"", "output[len(output)-1] == \"S\"", "output[len(output)-1]", "output", "len(output)-1", "len(output)", "len", "output", "1", "\"S\"", "X[i] == \"T\"", "X[i]", "X", "i", "\"T\"", "output.pop()", "output.pop", "output", "pop", "output.append(X[i])", "output.append", "output", "append", "X[i]", "X", "i", "output.append(X[i])", "output.append", "output", "append", "X[i]", "X", "i", "return len(output)", "len(output)", "len", "output", "X", "X", "def main():\n X = input()\n print(cal(X))", "main", "X = input()", "X", "input()", "input", "print(cal(X))", "print", "cal(X)", "cal", "X", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "def cal(X):\n output = []\n for i in range(len(X)):\n if len(output) > 0:\n if output[len(output)-1] == \"S\" and X[i] == \"T\":\n output.pop()\n else:\n output.append(X[i])\n else:\n output.append(X[i])\n\n return len(output)", "def cal(X):\n output = []\n for i in range(len(X)):\n if len(output) > 0:\n if output[len(output)-1] == \"S\" and X[i] == \"T\":\n output.pop()\n else:\n output.append(X[i])\n else:\n output.append(X[i])\n\n return len(output)", "cal", "def main():\n X = input()\n print(cal(X))", "def main():\n X = input()\n print(cal(X))", "main" ]
from bisect import bisect_right def cal(X): output = [] for i in range(len(X)): if len(output) > 0: if output[len(output)-1] == "S" and X[i] == "T": output.pop() else: output.append(X[i]) else: output.append(X[i]) return len(output) def main(): X = input() print(cal(X)) if __name__ == "__main__": main()
[ 7, 15, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 4, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 14, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 75, 3 ], [ 72, 7 ], [ 76, 10 ], [ 69, 12 ], [ 17, 16 ], [ 73, 19 ], [ 76, 23 ], [ 16, 24 ], [ 70, 28 ], [ 76, 31 ], [ 16, 32 ], [ 70, 37 ], [ 70, 41 ], [ 76, 44 ], [ 16, 45 ], [ 70, 49 ], [ 70, 54 ], [ 70, 58 ], [ 76, 61 ], [ 16, 62 ], [ 70, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "# coding: utf-8\nfrom collections import deque\ns=input()\nn=len(s)\nA=deque()\nfor i in range(n):\n if s[i]==\"S\":\n A.append(s[i])\n else:\n if len(A)==0:\n A.append(s[i])\n elif A[-1]==\"S\":\n A.pop()\n else:\n A.append(s[i])\nprint(len(A))", "from collections import deque", "s=input()", "s", "input()", "input", "n=len(s)", "n", "len(s)", "len", "s", "A=deque()", "A", "deque()", "deque", "for i in range(n):\n if s[i]==\"S\":\n A.append(s[i])\n else:\n if len(A)==0:\n A.append(s[i])\n elif A[-1]==\"S\":\n A.pop()\n else:\n A.append(s[i])", "i", "range(n)", "range", "n", "if s[i]==\"S\":\n A.append(s[i])\n else:\n if len(A)==0:\n A.append(s[i])\n elif A[-1]==\"S\":\n A.pop()\n else:\n A.append(s[i])", "s[i]==\"S\"", "s[i]", "s", "i", "\"S\"", "A.append(s[i])", "A.append", "A", "append", "s[i]", "s", "i", "if len(A)==0:\n A.append(s[i])\n elif A[-1]==\"S\":\n A.pop()\n else:\n A.append(s[i])", "len(A)==0", "len(A)", "len", "A", "0", "A.append(s[i])", "A.append", "A", "append", "s[i]", "s", "i", "elif A[-1]==\"S\":\n A.pop()\n ", "A[-1]==\"S\"", "A[-1]", "A", "-1", "\"S\"", "A.pop()", "A.pop", "A", "pop", "A.append(s[i])", "A.append", "A", "append", "s[i]", "s", "i", "print(len(A))", "print", "len(A)", "len", "A", "A=deque()", "deque()", "A", "n=len(s)", "len(s)", "n", "s=input()", "input()", "s" ]
# coding: utf-8 from collections import deque s=input() n=len(s) A=deque() for i in range(n): if s[i]=="S": A.append(s[i]) else: if len(A)==0: A.append(s[i]) elif A[-1]=="S": A.pop() else: A.append(s[i]) print(len(A))
[ 7, 0, 13, 18, 4, 18, 4, 18, 4, 13, 17, 13, 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, 2, 13, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 46, 2 ], [ 55, 15 ], [ 58, 18 ], [ 22, 21 ], [ 47, 21 ], [ 21, 25 ], [ 59, 29 ], [ 53, 29 ], [ 50, 29 ], [ 61, 32 ], [ 49, 35 ], [ 52, 38 ], [ 62, 43 ], [ 56, 43 ], [ 53, 44 ], [ 50, 44 ], [ 59, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "X = open(0).read().split()[0]\nans = 0\ns_count = 0\nfor x in X:\n if x == 'T':\n if s_count == 0:\n ans += 1\n else:\n s_count -= 1\n else:\n s_count += 1\nprint(ans+s_count)", "X = open(0).read().split()[0]", "X", "open(0).read().split()[0]", "(0).read().split()", "(0).read().split", "(0).read()", "(0).read", "(0)", "open", "0", "read", "split", "0", "ans = 0", "ans", "0", "s_count = 0", "s_count", "0", "for x in X:\n if x == 'T':\n if s_count == 0:\n ans += 1\n else:\n s_count -= 1\n else:\n s_count += 1", "x", "X", "if x == 'T':\n if s_count == 0:\n ans += 1\n else:\n s_count -= 1\n else:\n s_count += 1", "x == 'T'", "x", "'T'", "if s_count == 0:\n ans += 1\n else:\n s_count -= 1\n ", "s_count == 0", "s_count", "0", "ans += 1", "ans", "1", "s_count -= 1", "s_count", "1", "s_count += 1", "s_count", "1", "print(ans+s_count)", "print", "ans+s_count", "ans", "s_count", "X = open(0).read().split()[0]", "open(0).read().split()[0]", "X", "s_count -= 1", "1", "s_count", "s_count += 1", "1", "s_count", "ans = 0", "0", "ans", "s_count = 0", "0", "s_count", "ans += 1", "1", "ans" ]
X = open(0).read().split()[0] ans = 0 s_count = 0 for x in X: if x == 'T': if s_count == 0: ans += 1 else: s_count -= 1 else: s_count += 1 print(ans+s_count)
[ 7, 15, 15, 15, 15, 13, 4, 18, 13, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 0, 13, 4, 13, 13, 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, 17, 13, 10, 12, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 109, 12 ], [ 118, 39 ], [ 103, 43 ], [ 115, 46 ], [ 106, 49 ], [ 119, 52 ], [ 55, 54 ], [ 107, 57 ], [ 119, 61 ], [ 54, 62 ], [ 91, 65 ], [ 119, 70 ], [ 54, 71 ], [ 92, 75 ], [ 104, 75 ], [ 98, 75 ], [ 97, 78 ], [ 100, 81 ], [ 107, 86 ], [ 101, 88 ], [ 116, 88 ], [ 91, 92 ], [ 97, 98 ], [ 100, 101 ], [ 103, 104 ], [ 106, 107 ], [ 109, 110 ], [ 115, 116 ], [ 118, 119 ] ]
[ "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate # (string,3) 3回\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\n#import bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# pythonで無理なときは、pypyでやると正解するかも!!\n#\n#\n\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\nX = input()\nsc = 0\ncnt = 0\nln = len(X)\nfor i in range(ln):\n if X[i] == 'S':\n sc += 1\n if X[i] == 'T':\n if sc >= 1:\n sc -= 1\n cnt += 1\nprint(ln - cnt * 2)", "from fractions import gcd", "from itertools import combinations,permutations,accumulate", "from collections import deque,defaultdict,Counter", "import sys", "sys", "sys.setrecursionlimit(10000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10000000", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "def readInts():\n return list(map(int,input().split()))", "readInts", "return list(map(int,input().split()))", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def I():\n return int(input())", "I", "return int(input())", "int(input())", "int", "input()", "input", "X = input()", "X", "input()", "input", "sc = 0", "sc", "0", "cnt = 0", "cnt", "0", "ln = len(X)", "ln", "len(X)", "len", "X", "for i in range(ln):\n if X[i] == 'S':\n sc += 1\n if X[i] == 'T':\n if sc >= 1:\n sc -= 1\n cnt += 1", "i", "range(ln)", "range", "ln", "if X[i] == 'S':\n sc += 1\n ", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "sc += 1", "sc", "1", "if X[i] == 'T':\n if sc >= 1:\n sc -= 1\n cnt += 1", "X[i] == 'T'", "X[i]", "X", "i", "'T'", "if sc >= 1:\n sc -= 1\n cnt += 1", "sc >= 1", "sc", "1", "sc -= 1", "sc", "1", "cnt += 1", "cnt", "1", "print(ln - cnt * 2)", "print", "ln - cnt * 2", "ln", "cnt * 2", "cnt", "2", "sc += 1", "1", "sc", "def I():\n return int(input())", "def I():\n return int(input())", "I", "sc -= 1", "1", "sc", "cnt += 1", "1", "cnt", "sc = 0", "0", "sc", "ln = len(X)", "len(X)", "ln", "mod = 10**9 + 7", "10**9 + 7", "mod", "def readInts():\n return list(map(int,input().split()))", "def readInts():\n return list(map(int,input().split()))", "readInts", "cnt = 0", "0", "cnt", "X = input()", "input()", "X" ]
#from statistics import median #import collections #aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] from fractions import gcd from itertools import combinations,permutations,accumulate # (string,3) 3回 #from collections import deque from collections import deque,defaultdict,Counter #import bisect # # d = m - k[i] - k[j] # if kk[bisect.bisect_right(kk,d) - 1] == d: # # # # pythonで無理なときは、pypyでやると正解するかも!! # # import sys sys.setrecursionlimit(10000000) mod = 10**9 + 7 #mod = 9982443453 def readInts(): return list(map(int,input().split())) def I(): return int(input()) X = input() sc = 0 cnt = 0 ln = len(X) for i in range(ln): if X[i] == 'S': sc += 1 if X[i] == 'T': if sc >= 1: sc -= 1 cnt += 1 print(ln - cnt * 2)
[ 7, 15, 41, 28, 13, 13, 4, 13, 4, 13, 4, 13, 4, 39, 13, 4, 13, 4, 13, 13, 0, 13, 13, 0, 13, 17, 0, 13, 17, 14, 2, 18, 18, 13, 17, 17, 17, 0, 13, 18, 18, 13, 17, 17, 0, 13, 17, 0, 13, 17, 28, 39, 13, 13, 39, 13, 13, 4, 13, 18, 13, 39, 13, 17, 18, 13, 39, 2, 13, 17, 17, 14, 40, 2, 13, 13, 13, 0, 13, 2, 2, 13, 13, 13, 0, 13, 17, 4, 13, 2, 2, 13, 13, 8, 2, 18, 18, 13, 17, 17, 17, 17, 18, 18, 13, 17, 17, 10, 2, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 111, 21 ], [ 117, 24 ], [ 129, 27 ], [ 112, 33 ], [ 123, 38 ], [ 112, 41 ], [ 120, 45 ], [ 114, 48 ], [ 112, 60 ], [ 112, 65 ], [ 121, 68 ], [ 130, 68 ], [ 115, 75 ], [ 127, 75 ], [ 108, 78 ], [ 115, 83 ], [ 127, 83 ], [ 126, 85 ], [ 109, 91 ], [ 124, 91 ], [ 118, 91 ], [ 127, 92 ], [ 115, 92 ], [ 112, 97 ], [ 112, 104 ], [ 108, 109 ], [ 111, 112 ], [ 114, 115 ], [ 117, 118 ], [ 120, 121 ], [ 123, 124 ], [ 126, 127 ], [ 129, 130 ] ]
[ "from itertools import groupby as gb\nl=[(a,len(list(b))) for a,b in gb(list(input()))]\nans=0\nnow=0\nif l[0][0]==\"T\":\n ans+=l[0][1]\n now+=1\npres=0\nfor (k,x),(k1,y) in zip(l[now::2],l[now+1::2]):\n #print(ans,pres)\n if x+pres>=y:pres=(x+pres-y)\n else:\n ans+=y-x-pres\n pres=0\nprint(ans+pres+(0 if l[-1][0]==\"T\" else l[-1][1]))", "from itertools import groupby as gb", "(a,len(list(b))) for a,b in gb(list(input()))", "for a,b in gb(list(input()))", "a", "b", "gb(list(input()))", "gb", "list(input())", "list", "input()", "input", "for a,b in gb(list(input()))", "(a,len(list(b)))", "a", "len(list(b))", "len", "list(b)", "list", "b", "l=[(a,len(list(b))) for a,b in gb(list(input()))]", "l", "[(a,len(list(b))) for a,b in gb(list(input()))]", "ans=0", "ans", "0", "now=0", "now", "0", "if l[0][0]==\"T\":\n ans+=l[0][1]\n now+=1", "l[0][0]==\"T\"", "l[0][0]", "[0]", "l", "0", "0", "\"T\"", "ans+=l[0][1]", "ans", "l[0][1]", "[0]", "l", "0", "1", "now+=1", "now", "1", "pres=0", "pres", "0", "for (k,x),(k1,y) in zip(l[now::2],l[now+1::2]):\n #print(ans,pres)\n if x+pres>=y:pres=(x+pres-y)\n else:\n ans+=y-x-pres\n pres=0", "(k,x)", "k", "x", "(k1,y)", "k1", "y", "zip(l[now::2],l[now+1::2])", "zip", "l[now::2]", "l", "now::2", "now", "2", "l[now+1::2]", "l", "now+1::2", "now+1", "now", "1", "2", "if x+pres>=y:pres=(x+pres-y)\n else:\n ans+=y-x-pres\n pres=0", "x+pres>=y", "x+pres", "x", "pres", "y", "ans+=y-x-pres", "ans", "y-x-pres", "y-x", "y", "x", "pres", "pres=0", "pres", "0", "print(ans+pres+(0 if l[-1][0]==\"T\" else l[-1][1]))", "print", "ans+pres+(0 if l[-1][0]==\"T\" else l[-1][1])", "ans+pres", "ans", "pres", "0 if l[-1][0]==\"T\" else l[-1][1]", "l[-1][0]==\"T\"", "l[-1][0]", "[-1]", "l", "-1", "0", "\"T\"", "0", "l[-1][1]", "[-1]", "l", "-1", "1", "ans+=y-x-pres", "y-x-pres", "ans", "l=[(a,len(list(b))) for a,b in gb(list(input()))]", "[(a,len(list(b))) for a,b in gb(list(input()))]", "l", "pres=0", "0", "pres", "ans=0", "0", "ans", "now+=1", "1", "now", "ans+=l[0][1]", "l[0][1]", "ans", "pres=0", "0", "pres", "now=0", "0", "now" ]
from itertools import groupby as gb l=[(a,len(list(b))) for a,b in gb(list(input()))] ans=0 now=0 if l[0][0]=="T": ans+=l[0][1] now+=1 pres=0 for (k,x),(k1,y) in zip(l[now::2],l[now+1::2]): #print(ans,pres) if x+pres>=y:pres=(x+pres-y) else: ans+=y-x-pres pres=0 print(ans+pres+(0 if l[-1][0]=="T" else l[-1][1]))
[ 7, 12, 13, 15, 0, 13, 4, 13, 0, 13, 4, 13, 39, 4, 18, 13, 13, 18, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 17, 14, 40, 13, 4, 18, 13, 13, 17, 0, 13, 4, 18, 13, 13, 14, 2, 13, 17, 9, 4, 18, 13, 13, 17, 4, 18, 13, 13, 17, 4, 13, 4, 13, 13, 4, 13, 10, 12, 13 ]
[ [ 6, 5 ], [ 10, 9 ], [ 9, 15 ], [ 5, 18 ], [ 22, 21 ], [ 5, 27 ], [ 5, 31 ], [ 21, 32 ], [ 9, 36 ], [ 9, 41 ], [ 9, 44 ], [ 49, 48 ], [ 9, 51 ], [ 48, 55 ], [ 9, 60 ], [ 9, 65 ], [ 9, 72 ], [ 77, 74 ] ]
[ "def resolve():\n from collections import deque\n x = input()\n final = deque([])\n final.append(x[0])\n for i in range(1, len(x)):\n if x[i] == \"S\":\n final.append(\"S\")\n else:\n if not final:\n final.append(\"T\")\n else:\n last = final.pop()\n if last == \"S\":\n continue\n else:\n final.append(\"T\")\n final.append(\"T\")\n print(len(final))\nresolve()", "def resolve():\n from collections import deque\n x = input()\n final = deque([])\n final.append(x[0])\n for i in range(1, len(x)):\n if x[i] == \"S\":\n final.append(\"S\")\n else:\n if not final:\n final.append(\"T\")\n else:\n last = final.pop()\n if last == \"S\":\n continue\n else:\n final.append(\"T\")\n final.append(\"T\")\n print(len(final))", "resolve", "from collections import deque", "x = input()", "x", "input()", "input", "final = deque([])", "final", "deque([])", "deque", "[]", "final.append(x[0])", "final.append", "final", "append", "x[0]", "x", "0", "for i in range(1, len(x)):\n if x[i] == \"S\":\n final.append(\"S\")\n else:\n if not final:\n final.append(\"T\")\n else:\n last = final.pop()\n if last == \"S\":\n continue\n else:\n final.append(\"T\")\n final.append(\"T\")\n ", "i", "range(1, len(x))", "range", "1", "len(x)", "len", "x", "if x[i] == \"S\":\n final.append(\"S\")\n else:\n if not final:\n final.append(\"T\")\n else:\n last = final.pop()\n if last == \"S\":\n continue\n else:\n final.append(\"T\")\n final.append(\"T\")\n ", "x[i] == \"S\"", "x[i]", "x", "i", "\"S\"", "final.append(\"S\")", "final.append", "final", "append", "\"S\"", "if not final:\n final.append(\"T\")\n else:\n last = final.pop()\n if last == \"S\":\n continue\n else:\n final.append(\"T\")\n final.append(\"T\")\n ", "not final", "final", "final.append(\"T\")", "final.append", "final", "append", "\"T\"", "last = final.pop()", "last", "final.pop()", "final.pop", "final", "pop", "if last == \"S\":\n continue\n else:\n final.append(\"T\")\n final.append(\"T\")\n ", "last == \"S\"", "last", "\"S\"", "continue", "final.append(\"T\")", "final.append", "final", "append", "\"T\"", "final.append(\"T\")", "final.append", "final", "append", "\"T\"", "print(len(final))", "print", "len(final)", "len", "final", "resolve()", "resolve", "def resolve():\n from collections import deque\n x = input()\n final = deque([])\n final.append(x[0])\n for i in range(1, len(x)):\n if x[i] == \"S\":\n final.append(\"S\")\n else:\n if not final:\n final.append(\"T\")\n else:\n last = final.pop()\n if last == \"S\":\n continue\n else:\n final.append(\"T\")\n final.append(\"T\")\n print(len(final))", "def resolve():\n from collections import deque\n x = input()\n final = deque([])\n final.append(x[0])\n for i in range(1, len(x)):\n if x[i] == \"S\":\n final.append(\"S\")\n else:\n if not final:\n final.append(\"T\")\n else:\n last = final.pop()\n if last == \"S\":\n continue\n else:\n final.append(\"T\")\n final.append(\"T\")\n print(len(final))", "resolve" ]
def resolve(): from collections import deque x = input() final = deque([]) final.append(x[0]) for i in range(1, len(x)): if x[i] == "S": final.append("S") else: if not final: final.append("T") else: last = final.pop() if last == "S": continue else: final.append("T") final.append("T") print(len(final)) resolve()
[ 7, 0, 13, 4, 13, 0, 13, 18, 13, 17, 0, 13, 39, 0, 13, 17, 28, 13, 18, 13, 39, 17, 14, 40, 13, 13, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 13, 0, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 14, 2, 18, 13, 17, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 2, 13, 17, 17, 0, 13, 18, 13, 13, 0, 13, 18, 13, 13, 14, 2, 13, 13, 0, 13, 2, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 17, 13, 28, 13, 4, 13, 4, 13, 13, 14, 2, 2, 13, 17, 17, 0, 13, 18, 13, 13, 0, 13, 18, 13, 13, 14, 2, 13, 13, 0, 13, 2, 13, 13, 0, 13, 17, 0, 13, 17, 4, 13, 2, 17, 13, 10, 18, 13, 10, 18, 13, 10, 17, 13, 10, 17, 13, 10, 18, 13, 10, 17, 13, 10, 18, 13, 10, 17, 13, 10, 2, 13, 10, 17, 13, 10, 39, 13, 10, 17, 13, 10, 13, 13, 10, 2, 13, 10, 18, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 192, 2 ], [ 165, 6 ], [ 193, 8 ], [ 177, 11 ], [ 162, 14 ], [ 18, 17 ], [ 193, 19 ], [ 166, 24 ], [ 184, 24 ], [ 17, 25 ], [ 178, 28 ], [ 163, 30 ], [ 175, 30 ], [ 157, 30 ], [ 156, 32 ], [ 183, 35 ], [ 17, 36 ], [ 174, 38 ], [ 178, 42 ], [ 175, 44 ], [ 157, 44 ], [ 163, 44 ], [ 180, 46 ], [ 198, 49 ], [ 201, 52 ], [ 193, 57 ], [ 62, 61 ], [ 178, 66 ], [ 61, 70 ], [ 147, 74 ], [ 178, 76 ], [ 61, 77 ], [ 150, 79 ], [ 178, 81 ], [ 61, 82 ], [ 148, 85 ], [ 181, 85 ], [ 196, 85 ], [ 151, 86 ], [ 199, 86 ], [ 169, 86 ], [ 186, 88 ], [ 151, 90 ], [ 199, 90 ], [ 169, 90 ], [ 148, 91 ], [ 181, 91 ], [ 196, 91 ], [ 168, 93 ], [ 195, 96 ], [ 187, 102 ], [ 202, 102 ], [ 105, 104 ], [ 178, 109 ], [ 104, 113 ], [ 189, 117 ], [ 178, 119 ], [ 104, 120 ], [ 159, 122 ], [ 178, 124 ], [ 104, 125 ], [ 160, 128 ], [ 196, 128 ], [ 148, 128 ], [ 181, 128 ], [ 154, 128 ], [ 190, 129 ], [ 169, 129 ], [ 151, 129 ], [ 199, 129 ], [ 205, 129 ], [ 171, 131 ], [ 190, 133 ], [ 169, 133 ], [ 151, 133 ], [ 199, 133 ], [ 205, 133 ], [ 160, 134 ], [ 196, 134 ], [ 148, 134 ], [ 181, 134 ], [ 154, 134 ], [ 204, 136 ], [ 153, 139 ], [ 172, 145 ], [ 187, 145 ], [ 202, 145 ], [ 147, 148 ], [ 150, 151 ], [ 153, 154 ], [ 156, 157 ], [ 159, 160 ], [ 162, 163 ], [ 165, 166 ], [ 168, 169 ], [ 171, 172 ], [ 174, 175 ], [ 177, 178 ], [ 180, 181 ], [ 17, 183 ], [ 183, 184 ], [ 186, 187 ], [ 189, 190 ], [ 192, 193 ], [ 195, 196 ], [ 198, 199 ], [ 201, 202 ], [ 204, 205 ] ]
[ "X = input()\np = X[0]\nls = []\ncnt = 1\nfor c in X[1:]:\n if p!=c:\n ls.append(cnt)\n cnt = 1\n p = c\n else:\n cnt += 1\nls.append(cnt)\ns = 0\nt = 0\nm = 0\nif X[0]=='S':\n for i in range(len(ls)):\n if i%2==0:\n s += ls[i]\n else:\n t += ls[i]\n if s<t:\n m += t-s\n t = 0\n s = 0\n print(2*m)\nelse:\n for i in range(len(ls)):\n if i%2==0:\n t += ls[i]\n else:\n s += ls[i]\n if s<t:\n m += t-s\n t = 0\n s = 0\n print(2*m)", "X = input()", "X", "input()", "input", "p = X[0]", "p", "X[0]", "X", "0", "ls = []", "ls", "[]", "cnt = 1", "cnt", "1", "for c in X[1:]:\n if p!=c:\n ls.append(cnt)\n cnt = 1\n p = c\n else:\n cnt += 1", "c", "X[1:]", "X", "1:", "1", "if p!=c:\n ls.append(cnt)\n cnt = 1\n p = c\n else:\n cnt += 1", "p!=c", "p", "c", "ls.append(cnt)", "ls.append", "ls", "append", "cnt", "cnt = 1", "cnt", "1", "p = c", "p", "c", "cnt += 1", "cnt", "1", "ls.append(cnt)", "ls.append", "ls", "append", "cnt", "s = 0", "s", "0", "t = 0", "t", "0", "m = 0", "m", "0", "if X[0]=='S':\n for i in range(len(ls)):\n if i%2==0:\n s += ls[i]\n else:\n t += ls[i]\n if s<t:\n m += t-s\n t = 0\n s = 0\n print(2*m)\nelse:\n for i in range(len(ls)):\n if i%2==0:\n t += ls[i]\n else:\n s += ls[i]\n if s<t:\n m += t-s\n t = 0\n s = 0\n print(2*m)", "X[0]=='S'", "X[0]", "X", "0", "'S'", "for i in range(len(ls)):\n if i%2==0:\n s += ls[i]\n else:\n t += ls[i]\n if s<t:\n m += t-s\n t = 0\n s = 0\n ", "i", "range(len(ls))", "range", "len(ls)", "len", "ls", "if i%2==0:\n s += ls[i]\n else:\n t += ls[i]\n ", "i%2==0", "i%2", "i", "2", "0", "s += ls[i]", "s", "ls[i]", "ls", "i", "t += ls[i]", "t", "ls[i]", "ls", "i", "if s<t:\n m += t-s\n t = 0\n s = 0\n ", "s<t", "s", "t", "m += t-s", "m", "t-s", "t", "s", "t = 0", "t", "0", "s = 0", "s", "0", "print(2*m)", "print", "2*m", "2", "m", "for i in range(len(ls)):\n if i%2==0:\n t += ls[i]\n else:\n s += ls[i]\n if s<t:\n m += t-s\n t = 0\n s = 0\n ", "i", "range(len(ls))", "range", "len(ls)", "len", "ls", "if i%2==0:\n t += ls[i]\n else:\n s += ls[i]\n ", "i%2==0", "i%2", "i", "2", "0", "t += ls[i]", "t", "ls[i]", "ls", "i", "s += ls[i]", "s", "ls[i]", "ls", "i", "if s<t:\n m += t-s\n t = 0\n s = 0\n ", "s<t", "s", "t", "m += t-s", "m", "t-s", "t", "s", "t = 0", "t", "0", "s = 0", "s", "0", "print(2*m)", "print", "2*m", "2", "m", "s += ls[i]", "ls[i]", "s", "t += ls[i]", "ls[i]", "t", "s = 0", "0", "s", "cnt = 1", "1", "cnt", "s += ls[i]", "ls[i]", "s", "cnt = 1", "1", "cnt", "p = X[0]", "X[0]", "p", "t = 0", "0", "t", "m += t-s", "t-s", "m", "cnt += 1", "1", "cnt", "ls = []", "[]", "ls", "s = 0", "0", "s", "p = c", "c", "p", "m += t-s", "t-s", "m", "t += ls[i]", "ls[i]", "t", "X = input()", "input()", "X", "s = 0", "0", "s", "t = 0", "0", "t", "m = 0", "0", "m", "t = 0", "0", "t" ]
X = input() p = X[0] ls = [] cnt = 1 for c in X[1:]: if p!=c: ls.append(cnt) cnt = 1 p = c else: cnt += 1 ls.append(cnt) s = 0 t = 0 m = 0 if X[0]=='S': for i in range(len(ls)): if i%2==0: s += ls[i] else: t += ls[i] if s<t: m += t-s t = 0 s = 0 print(2*m) else: for i in range(len(ls)): if i%2==0: t += ls[i] else: s += ls[i] if s<t: m += t-s t = 0 s = 0 print(2*m)
[ 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, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 48, 2 ], [ 39, 6 ], [ 42, 9 ], [ 13, 12 ], [ 49, 12 ], [ 12, 16 ], [ 45, 19 ], [ 51, 22 ], [ 36, 25 ], [ 40, 28 ], [ 37, 28 ], [ 52, 29 ], [ 46, 29 ], [ 43, 29 ], [ 37, 33 ], [ 40, 33 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "X = input()\n\nans = 0\nt = 0\nfor x in X:\n if x == \"S\":\n t -= 1\n else:\n t += 1\n ans = max(ans, t)\n\nprint(ans * 2)", "X = input()", "X", "input()", "input", "ans = 0", "ans", "0", "t = 0", "t", "0", "for x in X:\n if x == \"S\":\n t -= 1\n else:\n t += 1\n ans = max(ans, t)", "x", "X", "if x == \"S\":\n t -= 1\n else:\n t += 1\n ", "x == \"S\"", "x", "\"S\"", "t -= 1", "t", "1", "t += 1", "t", "1", "ans = max(ans, t)", "ans", "max(ans, t)", "max", "ans", "t", "print(ans * 2)", "print", "ans * 2", "ans", "2", "ans = max(ans, t)", "max(ans, t)", "ans", "ans = 0", "0", "ans", "t = 0", "0", "t", "t -= 1", "1", "t", "X = input()", "input()", "X", "t += 1", "1", "t" ]
X = input() ans = 0 t = 0 for x in X: if x == "S": t -= 1 else: t += 1 ans = max(ans, t) print(ans * 2)
[ 7, 0, 13, 4, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 2, 4, 13, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 41, 2 ], [ 44, 6 ], [ 44, 9 ], [ 13, 12 ], [ 42, 12 ], [ 12, 16 ], [ 45, 20 ], [ 51, 20 ], [ 50, 23 ], [ 47, 26 ], [ 42, 33 ], [ 48, 35 ], [ 39, 35 ], [ 44, 39 ], [ 41, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ] ]
[ "s = input()\ns_cnt = puyo = 0\nfor si in s:\n if si == \"S\": s_cnt += 1\n elif s_cnt > 0:\n s_cnt -= 1\n puyo += 1\nprint(len(s) - puyo * 2)", "s = input()", "s", "input()", "input", "s_cnt = puyo = 0", "s_cnt", "0", "= puyo = 0", "puyo", "0", "for si in s:\n if si == \"S\": s_cnt += 1\n elif s_cnt > 0:\n s_cnt -= 1\n puyo += 1", "si", "s", "if si == \"S\": s_cnt += 1\n elif s_cnt > 0:\n s_cnt -= 1\n puyo += 1", "si == \"S\"", "si", "\"S\"", "elif s_cnt > 0:\n s_cnt -= 1\n puyo += 1", "s_cnt > 0", "s_cnt", "0", "s_cnt -= 1", "s_cnt", "1", "puyo += 1", "puyo", "1", "print(len(s) - puyo * 2)", "print", "len(s) - puyo * 2", "len(s)", "len", "s", "puyo * 2", "puyo", "2", "puyo = 0", "0", "puyo", "s = input()", "input()", "s", "s_cnt = puyo = 0", "0", "s_cnt", "puyo += 1", "1", "puyo", "s_cnt -= 1", "1", "s_cnt" ]
s = input() s_cnt = puyo = 0 for si in s: if si == "S": s_cnt += 1 elif s_cnt > 0: s_cnt -= 1 puyo += 1 print(len(s) - puyo * 2)
[ 7, 0, 13, 4, 18, 4, 13, 13, 0, 13, 39, 18, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 14, 2, 2, 2, 18, 13, 13, 17, 2, 4, 13, 13, 17, 2, 18, 13, 17, 17, 4, 18, 13, 13, 4, 18, 13, 13, 18, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 39, 13 ]
[ [ 57, 2 ], [ 60, 9 ], [ 58, 12 ], [ 16, 15 ], [ 58, 21 ], [ 58, 27 ], [ 15, 28 ], [ 61, 33 ], [ 61, 37 ], [ 61, 42 ], [ 61, 46 ], [ 58, 49 ], [ 15, 50 ], [ 61, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "X = input().strip()\nA = [X[0]]\nfor i in range(1,len(X)):\n if X[i]==\"T\" and len(A)>0 and A[-1]==\"S\":\n A.pop()\n else:\n A.append(X[i])\nprint(len(A))", "X = input().strip()", "X", "input().strip()", "().strip", "()", "input", "strip", "A = [X[0]]", "A", "[X[0]]", "X[0]", "X", "0", "for i in range(1,len(X)):\n if X[i]==\"T\" and len(A)>0 and A[-1]==\"S\":\n A.pop()\n else:\n A.append(X[i])", "i", "range(1,len(X))", "range", "1", "len(X)", "len", "X", "if X[i]==\"T\" and len(A)>0 and A[-1]==\"S\":\n A.pop()\n else:\n A.append(X[i])", "X[i]==\"T\" and len(A)>0 and A[-1]==\"S\"", "X[i]==\"T\" and len(A)>0", "X[i]==\"T\"", "X[i]", "X", "i", "\"T\"", "len(A)>0", "len(A)", "len", "A", "0", "A[-1]==\"S\"", "A[-1]", "A", "-1", "\"S\"", "A.pop()", "A.pop", "A", "pop", "A.append(X[i])", "A.append", "A", "append", "X[i]", "X", "i", "print(len(A))", "print", "len(A)", "len", "A", "X = input().strip()", "input().strip()", "X", "A = [X[0]]", "[X[0]]", "A" ]
X = input().strip() A = [X[0]] for i in range(1,len(X)): if X[i]=="T" and len(A)>0 and A[-1]=="S": A.pop() else: A.append(X[i]) print(len(A))
[ 7, 15, 13, 13, 13, 13, 13, 13, 13, 13, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 2, 4, 13, 13, 17, 12, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 12, 13, 12, 13, 12, 13, 0, 13, 4, 13, 0, 13, 39, 0, 13, 4, 13, 13, 0, 13, 13, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 17, 14, 2, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 144, 11 ], [ 162, 30 ], [ 43, 42 ], [ 145, 46 ], [ 42, 51 ], [ 57, 56 ], [ 145, 60 ], [ 56, 66 ], [ 73, 72 ], [ 145, 76 ], [ 72, 81 ], [ 90, 89 ], [ 154, 91 ], [ 94, 93 ], [ 97, 96 ], [ 89, 99 ], [ 102, 101 ], [ 96, 102 ], [ 105, 104 ], [ 96, 107 ], [ 89, 111 ], [ 104, 112 ], [ 93, 116 ], [ 93, 121 ], [ 93, 124 ], [ 93, 129 ], [ 133, 132 ], [ 132, 136 ], [ 101, 136 ], [ 148, 142 ], [ 144, 145 ], [ 162, 163 ] ]
[ "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n X = SS()\n\n stk = []\n\n len_X = len(X)\n ans = len_X\n for i in range(len_X):\n if X[i] == 'S':\n stk.append('S')\n else:\n if stk and stk[-1] == 'S':\n stk.pop()\n ans -= 2\n\n print(ans)\n\nif __name__ == '__main__':\n resolve()", "import bisect, collections, copy, heapq, itertools, math, string, sys", "bisect", "collections", "copy", "heapq", "itertools", "math", "string", "sys", "input = lambda: sys.stdin.readline().rstrip()", "input", "lambda: sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "sys.setrecursionlimit(10**7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**7", "10", "7", "INF = float('inf')", "INF", "float('inf')", "float", "'inf'", "def I(): return int(input())", "I", "def F(): return float(input())", "F", "def SS(): return input()", "SS", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "def LI(): return [int(x) for x in input().split()]", "LI", "int(x)-1 for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)-1", "int(x)", "int", "x", "1", "def LI_(): return [int(x)-1 for x in input().split()]", "LI_", "float(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "float(x)", "float", "x", "def LF(): return [float(x) for x in input().split()]", "LF", "def LSS(): return input().split()", "LSS", "def resolve():\n X = SS()\n\n stk = []\n\n len_X = len(X)\n ans = len_X\n for i in range(len_X):\n if X[i] == 'S':\n stk.append('S')\n else:\n if stk and stk[-1] == 'S':\n stk.pop()\n ans -= 2\n\n print(ans)", "resolve", "X = SS()", "X", "SS()", "SS", "stk = []", "stk", "[]", "len_X = len(X)", "len_X", "len(X)", "len", "X", "ans = len_X", "ans", "len_X", "for i in range(len_X):\n if X[i] == 'S':\n stk.append('S')\n else:\n if stk and stk[-1] == 'S':\n stk.pop()\n ans -= 2\n\n ", "i", "range(len_X)", "range", "len_X", "if X[i] == 'S':\n stk.append('S')\n else:\n if stk and stk[-1] == 'S':\n stk.pop()\n ans -= 2\n\n ", "X[i] == 'S'", "X[i]", "X", "i", "'S'", "stk.append('S')", "stk.append", "stk", "append", "'S'", "if stk and stk[-1] == 'S':\n stk.pop()\n ans -= 2\n\n ", "stk and stk[-1] == 'S'", "stk", "stk[-1] == 'S'", "stk[-1]", "stk", "-1", "'S'", "stk.pop()", "stk.pop", "stk", "pop", "ans -= 2", "ans", "2", "print(ans)", "print", "ans", "if __name__ == '__main__':\n resolve()", "__name__ == '__main__'", "__name__", "'__main__'", "resolve()", "resolve", "input = lambda: sys.stdin.readline().rstrip()", "lambda: sys.stdin.readline().rstrip()", "input", "def resolve():\n X = SS()\n\n stk = []\n\n len_X = len(X)\n ans = len_X\n for i in range(len_X):\n if X[i] == 'S':\n stk.append('S')\n else:\n if stk and stk[-1] == 'S':\n stk.pop()\n ans -= 2\n\n print(ans)", "def resolve():\n X = SS()\n\n stk = []\n\n len_X = len(X)\n ans = len_X\n for i in range(len_X):\n if X[i] == 'S':\n stk.append('S')\n else:\n if stk and stk[-1] == 'S':\n stk.pop()\n ans -= 2\n\n print(ans)", "resolve", "def F(): return float(input())", "def F(): return float(input())", "F", "def SS(): return input()", "def SS(): return input()", "SS", "def LI(): return [int(x) for x in input().split()]", "def LI(): return [int(x) for x in input().split()]", "LI", "def I(): return int(input())", "def I(): return int(input())", "I", "INF = float('inf')", "float('inf')", "INF", "def LSS(): return input().split()", "def LSS(): return input().split()", "LSS", "def LF(): return [float(x) for x in input().split()]", "def LF(): return [float(x) for x in input().split()]", "LF", "def LI_(): return [int(x)-1 for x in input().split()]", "def LI_(): return [int(x)-1 for x in input().split()]", "LI_" ]
import bisect, collections, copy, heapq, itertools, math, string, sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**7) INF = float('inf') def I(): return int(input()) def F(): return float(input()) def SS(): return input() def LI(): return [int(x) for x in input().split()] def LI_(): return [int(x)-1 for x in input().split()] def LF(): return [float(x) for x in input().split()] def LSS(): return input().split() def resolve(): X = SS() stk = [] len_X = len(X) ans = len_X for i in range(len_X): if X[i] == 'S': stk.append('S') else: if stk and stk[-1] == 'S': stk.pop() ans -= 2 print(ans) if __name__ == '__main__': resolve()
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 18, 18, 13, 13, 13, 12, 13, 0, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 2, 13, 17, 13, 0, 13, 17, 0, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 18, 13, 10, 12, 13 ]
[ [ 66, 11 ], [ 21, 20 ], [ 67, 24 ], [ 28, 27 ], [ 20, 30 ], [ 33, 32 ], [ 36, 35 ], [ 20, 35 ], [ 35, 39 ], [ 43, 42 ], [ 35, 47 ], [ 32, 49 ], [ 54, 49 ], [ 42, 49 ], [ 52, 51 ], [ 55, 54 ], [ 51, 58 ], [ 27, 58 ], [ 70, 64 ], [ 66, 67 ] ]
[ "import sys\n\nsys.setrecursionlimit(10 ** 7)\nrl = sys.stdin.readline\n\n\ndef solve():\n X = rl().rstrip()\n \n ans = len(X)\n cnt_s = 0\n for xi in X:\n if xi == 'S':\n cnt_s += 1\n elif xi == 'T' and cnt_s:\n ans -= 2\n cnt_s -= 1\n print(ans)\n\n\nif __name__ == '__main__':\n solve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "rl = sys.stdin.readline", "rl", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "def solve():\n X = rl().rstrip()\n \n ans = len(X)\n cnt_s = 0\n for xi in X:\n if xi == 'S':\n cnt_s += 1\n elif xi == 'T' and cnt_s:\n ans -= 2\n cnt_s -= 1\n print(ans)", "solve", "X = rl().rstrip()", "X", "rl().rstrip()", "().rstrip", "()", "rl", "rstrip", "ans = len(X)", "ans", "len(X)", "len", "X", "cnt_s = 0", "cnt_s", "0", "for xi in X:\n if xi == 'S':\n cnt_s += 1\n elif xi == 'T' and cnt_s:\n ans -= 2\n cnt_s -= 1\n ", "xi", "X", "if xi == 'S':\n cnt_s += 1\n elif xi == 'T' and cnt_s:\n ans -= 2\n cnt_s -= 1\n ", "xi == 'S'", "xi", "'S'", "cnt_s += 1", "cnt_s", "1", "elif xi == 'T' and cnt_s:\n ans -= 2\n cnt_s -= 1\n ", "xi == 'T' and cnt_s", "xi == 'T'", "xi", "'T'", "cnt_s", "ans -= 2", "ans", "2", "cnt_s -= 1", "cnt_s", "1", "print(ans)", "print", "ans", "if __name__ == '__main__':\n solve()", "__name__ == '__main__'", "__name__", "'__main__'", "solve()", "solve", "rl = sys.stdin.readline", "sys.stdin.readline", "rl", "def solve():\n X = rl().rstrip()\n \n ans = len(X)\n cnt_s = 0\n for xi in X:\n if xi == 'S':\n cnt_s += 1\n elif xi == 'T' and cnt_s:\n ans -= 2\n cnt_s -= 1\n print(ans)", "def solve():\n X = rl().rstrip()\n \n ans = len(X)\n cnt_s = 0\n for xi in X:\n if xi == 'S':\n cnt_s += 1\n elif xi == 'T' and cnt_s:\n ans -= 2\n cnt_s -= 1\n print(ans)", "solve" ]
import sys sys.setrecursionlimit(10 ** 7) rl = sys.stdin.readline def solve(): X = rl().rstrip() ans = len(X) cnt_s = 0 for xi in X: if xi == 'S': cnt_s += 1 elif xi == 'T' and cnt_s: ans -= 2 cnt_s -= 1 print(ans) if __name__ == '__main__': solve()
[ 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, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 59, 2 ], [ 53, 6 ], [ 60, 9 ], [ 47, 11 ], [ 62, 14 ], [ 54, 15 ], [ 18, 17 ], [ 54, 20 ], [ 60, 24 ], [ 17, 25 ], [ 44, 28 ], [ 48, 32 ], [ 57, 32 ], [ 45, 32 ], [ 50, 35 ], [ 56, 38 ], [ 51, 42 ], [ 63, 42 ], [ 44, 45 ], [ 47, 48 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 54, 62 ], [ 62, 63 ] ]
[ "X = input()\nN = len(X)\n\ncnt_s = 0\nans = N\nfor i in range(N):\n if X[i] == \"S\":\n cnt_s += 1\n else:\n if cnt_s > 0:\n ans -= 2\n cnt_s -= 1\n\nprint(ans)", "X = input()", "X", "input()", "input", "N = len(X)", "N", "len(X)", "len", "X", "cnt_s = 0", "cnt_s", "0", "ans = N", "ans", "N", "for i in range(N):\n if X[i] == \"S\":\n cnt_s += 1\n else:\n if cnt_s > 0:\n ans -= 2\n cnt_s -= 1", "i", "range(N)", "range", "N", "if X[i] == \"S\":\n cnt_s += 1\n else:\n if cnt_s > 0:\n ans -= 2\n cnt_s -= 1", "X[i] == \"S\"", "X[i]", "X", "i", "\"S\"", "cnt_s += 1", "cnt_s", "1", "if cnt_s > 0:\n ans -= 2\n cnt_s -= 1", "cnt_s > 0", "cnt_s", "0", "ans -= 2", "ans", "2", "cnt_s -= 1", "cnt_s", "1", "print(ans)", "print", "ans", "cnt_s += 1", "1", "cnt_s", "cnt_s = 0", "0", "cnt_s", "ans -= 2", "2", "ans", "N = len(X)", "len(X)", "N", "cnt_s -= 1", "1", "cnt_s", "X = input()", "input()", "X", "ans = N", "N", "ans" ]
X = input() N = len(X) cnt_s = 0 ans = N for i in range(N): if X[i] == "S": cnt_s += 1 else: if cnt_s > 0: ans -= 2 cnt_s -= 1 print(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, 17, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 39, 6 ], [ 45, 8 ], [ 12, 11 ], [ 52, 11 ], [ 11, 15 ], [ 36, 18 ], [ 40, 22 ], [ 43, 22 ], [ 37, 22 ], [ 48, 25 ], [ 42, 28 ], [ 43, 33 ], [ 37, 33 ], [ 40, 33 ], [ 49, 34 ], [ 46, 34 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "S = input()\ns, t = 0, 0\nfor i in S:\n if i == \"S\":\n s += 1\n else:\n if s == 0:\n t += 1\n else:\n s -= 1\nprint(s + t)", "S = input()", "S", "input()", "input", "s, t = 0, 0", "s", "0", "t", "0", "for i in S:\n if i == \"S\":\n s += 1\n else:\n if s == 0:\n t += 1\n else:\n s -= 1", "i", "S", "if i == \"S\":\n s += 1\n else:\n if s == 0:\n t += 1\n else:\n s -= 1", "i == \"S\"", "i", "\"S\"", "s += 1", "s", "1", "if s == 0:\n t += 1\n else:\n s -= 1", "s == 0", "s", "0", "t += 1", "t", "1", "s -= 1", "s", "1", "print(s + t)", "print", "s + t", "s", "t", "s += 1", "1", "s", "s, t = 0, 0", "0", "s", "s -= 1", "1", "s", "t = 0, 0", "0", "t", "t += 1", "1", "t", "S = input()", "input()", "S" ]
S = input() s, t = 0, 0 for i in S: if i == "S": s += 1 else: if s == 0: t += 1 else: s -= 1 print(s + t)
[ 7, 0, 13, 4, 13, 0, 13, 39, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 14, 2, 18, 13, 13, 17, 4, 18, 13, 13, 18, 13, 13, 0, 13, 17, 14, 2, 13, 17, 4, 18, 13, 13, 18, 13, 13, 0, 13, 17, 14, 2, 18, 13, 2, 13, 17, 17, 4, 18, 13, 13, 18, 13, 13, 0, 13, 17, 14, 2, 18, 13, 2, 13, 17, 17, 24, 18, 13, 2, 13, 17, 0, 13, 17, 4, 13, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 39, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 92, 2 ], [ 98, 6 ], [ 101, 9 ], [ 13, 12 ], [ 93, 17 ], [ 93, 21 ], [ 12, 22 ], [ 99, 26 ], [ 93, 29 ], [ 12, 30 ], [ 107, 32 ], [ 102, 36 ], [ 105, 36 ], [ 90, 36 ], [ 96, 36 ], [ 108, 36 ], [ 99, 40 ], [ 93, 43 ], [ 12, 44 ], [ 95, 46 ], [ 99, 51 ], [ 102, 53 ], [ 105, 53 ], [ 90, 53 ], [ 96, 53 ], [ 108, 53 ], [ 99, 58 ], [ 93, 61 ], [ 12, 62 ], [ 89, 64 ], [ 99, 69 ], [ 102, 71 ], [ 105, 71 ], [ 90, 71 ], [ 96, 71 ], [ 108, 71 ], [ 99, 76 ], [ 102, 78 ], [ 105, 78 ], [ 90, 78 ], [ 96, 78 ], [ 108, 78 ], [ 104, 81 ], [ 99, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ] ]
[ "X=input()\nstack=[]\npoint=0\nfor i in range(len(X)):\n if X[i]==\"S\":\n stack.append(X[i])\n point+=1\n else:\n if point==0:\n stack.append(X[i])\n point+=1\n elif stack[point-1]==\"T\":\n stack.append(X[i])\n point+=1\n elif stack[point-1]==\"S\":\n del stack[point-1]\n point-=1\nprint(len(stack))", "X=input()", "X", "input()", "input", "stack=[]", "stack", "[]", "point=0", "point", "0", "for i in range(len(X)):\n if X[i]==\"S\":\n stack.append(X[i])\n point+=1\n else:\n if point==0:\n stack.append(X[i])\n point+=1\n elif stack[point-1]==\"T\":\n stack.append(X[i])\n point+=1\n elif stack[point-1]==\"S\":\n del stack[point-1]\n point-=1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i]==\"S\":\n stack.append(X[i])\n point+=1\n else:\n if point==0:\n stack.append(X[i])\n point+=1\n elif stack[point-1]==\"T\":\n stack.append(X[i])\n point+=1\n elif stack[point-1]==\"S\":\n del stack[point-1]\n point-=1", "X[i]==\"S\"", "X[i]", "X", "i", "\"S\"", "stack.append(X[i])", "stack.append", "stack", "append", "X[i]", "X", "i", "point+=1", "point", "1", "if point==0:\n stack.append(X[i])\n point+=1\n elif stack[point-1]==\"T\":\n stack.append(X[i])\n point+=1\n elif stack[point-1]==\"S\":\n del stack[point-1]\n point-=1", "point==0", "point", "0", "stack.append(X[i])", "stack.append", "stack", "append", "X[i]", "X", "i", "point+=1", "point", "1", "elif stack[point-1]==\"T\":\n stack.append(X[i])\n point+=1\n ", "stack[point-1]==\"T\"", "stack[point-1]", "stack", "point-1", "point", "1", "\"T\"", "stack.append(X[i])", "stack.append", "stack", "append", "X[i]", "X", "i", "point+=1", "point", "1", "elif stack[point-1]==\"S\":\n del stack[point-1]\n point-=1", "stack[point-1]==\"S\"", "stack[point-1]", "stack", "point-1", "point", "1", "\"S\"", "del stack[point-1]", "stack[point-1]", "stack", "point-1", "point", "1", "point-=1", "point", "1", "print(len(stack))", "print", "len(stack)", "len", "stack", "point+=1", "1", "point", "X=input()", "input()", "X", "point+=1", "1", "point", "stack=[]", "[]", "stack", "point=0", "0", "point", "point-=1", "1", "point", "point+=1", "1", "point" ]
X=input() stack=[] point=0 for i in range(len(X)): if X[i]=="S": stack.append(X[i]) point+=1 else: if point==0: stack.append(X[i]) point+=1 elif stack[point-1]=="T": stack.append(X[i]) point+=1 elif stack[point-1]=="S": del stack[point-1] point-=1 print(len(stack))
[ 7, 0, 13, 4, 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, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 46, 2 ], [ 52, 6 ], [ 10, 9 ], [ 47, 14 ], [ 47, 18 ], [ 9, 19 ], [ 40, 22 ], [ 53, 26 ], [ 44, 26 ], [ 50, 26 ], [ 41, 26 ], [ 49, 29 ], [ 43, 32 ], [ 44, 37 ], [ 50, 37 ], [ 41, 37 ], [ 53, 37 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "X=input()\n\nans=0\nfor i in range(len(X)):\n if X[i]=='S':\n ans+=1\n else:\n if ans==0:\n ans=0\n else:\n ans-=1\nprint(ans*2)", "X=input()", "X", "input()", "input", "ans=0", "ans", "0", "for i in range(len(X)):\n if X[i]=='S':\n ans+=1\n else:\n if ans==0:\n ans=0\n else:\n ans-=1", "i", "range(len(X))", "range", "len(X)", "len", "X", "if X[i]=='S':\n ans+=1\n else:\n if ans==0:\n ans=0\n else:\n ans-=1", "X[i]=='S'", "X[i]", "X", "i", "'S'", "ans+=1", "ans", "1", "if ans==0:\n ans=0\n else:\n ans-=1", "ans==0", "ans", "0", "ans=0", "ans", "0", "ans-=1", "ans", "1", "print(ans*2)", "print", "ans*2", "ans", "2", "ans+=1", "1", "ans", "ans-=1", "1", "ans", "X=input()", "input()", "X", "ans=0", "0", "ans", "ans=0", "0", "ans" ]
X=input() ans=0 for i in range(len(X)): if X[i]=='S': ans+=1 else: if ans==0: ans=0 else: ans-=1 print(ans*2)
[ 7, 0, 13, 4, 13, 0, 13, 39, 17, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 2, 18, 13, 17, 17, 4, 13, 2, 4, 13, 4, 13, 13, 17, 17, 10, 39, 13, 10, 4, 13 ]
[ [ 48, 2 ], [ 45, 6 ], [ 11, 10 ], [ 49, 10 ], [ 10, 14 ], [ 46, 18 ], [ 46, 22 ], [ 46, 27 ], [ 46, 31 ], [ 46, 41 ], [ 45, 46 ], [ 48, 49 ] ]
[ "x = input()\nnum = [0]\nfor i in x:\n if i == \"S\":\n num.append(num[-1] - 1)\n else:\n num.append(num[-1] + 1)\nprint(max(max(num), 0) * 2)", "x = input()", "x", "input()", "input", "num = [0]", "num", "[0]", "0", "for i in x:\n if i == \"S\":\n num.append(num[-1] - 1)\n else:\n num.append(num[-1] + 1)", "i", "x", "if i == \"S\":\n num.append(num[-1] - 1)\n else:\n num.append(num[-1] + 1)", "i == \"S\"", "i", "\"S\"", "num.append(num[-1] - 1)", "num.append", "num", "append", "num[-1] - 1", "num[-1]", "num", "-1", "1", "num.append(num[-1] + 1)", "num.append", "num", "append", "num[-1] + 1", "num[-1]", "num", "-1", "1", "print(max(max(num), 0) * 2)", "print", "max(max(num), 0) * 2", "max(max(num), 0)", "max", "max(num)", "max", "num", "0", "2", "num = [0]", "[0]", "num", "x = input()", "input()", "x" ]
x = input() num = [0] for i in x: if i == "S": num.append(num[-1] - 1) else: num.append(num[-1] + 1) print(max(max(num), 0) * 2)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 0, 13, 17, 14, 2, 13, 17, 0, 13, 17, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 40, 2 ], [ 49, 6 ], [ 41, 9 ], [ 52, 11 ], [ 15, 14 ], [ 41, 14 ], [ 14, 18 ], [ 43, 21 ], [ 53, 25 ], [ 47, 25 ], [ 44, 25 ], [ 37, 28 ], [ 46, 31 ], [ 38, 35 ], [ 50, 35 ], [ 37, 38 ], [ 40, 41 ], [ 43, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "X = input()\n\nans = len(X)\ntmp_s = 0\nfor i in X:\n if i == \"S\":\n tmp_s += 1\n else:\n if tmp_s > 0:\n ans -= 2\n tmp_s -= 1\n\nprint(ans)", "X = input()", "X", "input()", "input", "ans = len(X)", "ans", "len(X)", "len", "X", "tmp_s = 0", "tmp_s", "0", "for i in X:\n if i == \"S\":\n tmp_s += 1\n else:\n if tmp_s > 0:\n ans -= 2\n tmp_s -= 1", "i", "X", "if i == \"S\":\n tmp_s += 1\n else:\n if tmp_s > 0:\n ans -= 2\n tmp_s -= 1", "i == \"S\"", "i", "\"S\"", "tmp_s += 1", "tmp_s", "1", "if tmp_s > 0:\n ans -= 2\n tmp_s -= 1", "tmp_s > 0", "tmp_s", "0", "ans -= 2", "ans", "2", "tmp_s -= 1", "tmp_s", "1", "print(ans)", "print", "ans", "ans -= 2", "2", "ans", "X = input()", "input()", "X", "tmp_s += 1", "1", "tmp_s", "tmp_s -= 1", "1", "tmp_s", "ans = len(X)", "len(X)", "ans", "tmp_s = 0", "0", "tmp_s" ]
X = input() ans = len(X) tmp_s = 0 for i in X: if i == "S": tmp_s += 1 else: if tmp_s > 0: ans -= 2 tmp_s -= 1 print(ans)
[ 7, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 39, 17, 0, 13, 39, 17, 0, 13, 17, 28, 13, 13, 14, 2, 13, 17, 4, 18, 13, 13, 2, 18, 13, 17, 17, 4, 18, 13, 13, 18, 13, 17, 4, 18, 13, 13, 18, 13, 17, 4, 18, 13, 13, 2, 18, 13, 17, 17, 14, 2, 13, 17, 0, 13, 4, 13, 13, 2, 18, 13, 17, 18, 13, 17, 0, 13, 2, 17, 13, 4, 13, 13, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 11, 10 ], [ 15, 14 ], [ 19, 18 ], [ 22, 21 ], [ 4, 21 ], [ 21, 25 ], [ 10, 29 ], [ 10, 33 ], [ 14, 38 ], [ 14, 41 ], [ 10, 45 ], [ 10, 48 ], [ 14, 52 ], [ 14, 56 ], [ 21, 61 ], [ 65, 64 ], [ 18, 67 ], [ 64, 67 ], [ 14, 70 ], [ 10, 73 ], [ 77, 76 ], [ 64, 79 ], [ 18, 79 ], [ 76, 82 ], [ 87, 84 ] ]
[ "def agc005_a():\n x = str(input())\n s_accum = [0]\n t_accum = [0]\n t_up = 0\n for ch in x:\n # SとTの出現回数の累積和\n if ch == 'S':\n s_accum.append(s_accum[-1] + 1)\n t_accum.append(t_accum[-1])\n else:\n s_accum.append(s_accum[-1])\n t_accum.append(t_accum[-1] + 1)\n # Tの左側にいるSとの差分が、残るTの数で、プラスの値ならTが先頭に残る\n if ch == 'T':\n t_up = max(t_up, t_accum[-1] - s_accum[-1])\n ans = 2 * t_up\n print(ans)\n\nagc005_a()", "def agc005_a():\n x = str(input())\n s_accum = [0]\n t_accum = [0]\n t_up = 0\n for ch in x:\n # SとTの出現回数の累積和\n if ch == 'S':\n s_accum.append(s_accum[-1] + 1)\n t_accum.append(t_accum[-1])\n else:\n s_accum.append(s_accum[-1])\n t_accum.append(t_accum[-1] + 1)\n # Tの左側にいるSとの差分が、残るTの数で、プラスの値ならTが先頭に残る\n if ch == 'T':\n t_up = max(t_up, t_accum[-1] - s_accum[-1])\n ans = 2 * t_up\n print(ans)", "agc005_a", "x = str(input())", "x", "str(input())", "str", "input()", "input", "s_accum = [0]", "s_accum", "[0]", "0", "t_accum = [0]", "t_accum", "[0]", "0", "t_up = 0", "t_up", "0", "for ch in x:\n # SとTの出現回数の累積和\n if ch == 'S':\n s_accum.append(s_accum[-1] + 1)\n t_accum.append(t_accum[-1])\n else:\n s_accum.append(s_accum[-1])\n t_accum.append(t_accum[-1] + 1)\n # Tの左側にいるSとの差分が、残るTの数で、プラスの値ならTが先頭に残る\n if ch == 'T':\n t_up = max(t_up, t_accum[-1] - s_accum[-1])\n ", "ch", "x", "if ch == 'S':\n s_accum.append(s_accum[-1] + 1)\n t_accum.append(t_accum[-1])\n else:\n s_accum.append(s_accum[-1])\n t_accum.append(t_accum[-1] + 1)\n # Tの左側にいるSとの差分が、残るTの数で、プラスの値ならTが先頭に残る\n ", "ch == 'S'", "ch", "'S'", "s_accum.append(s_accum[-1] + 1)", "s_accum.append", "s_accum", "append", "s_accum[-1] + 1", "s_accum[-1]", "s_accum", "-1", "1", "t_accum.append(t_accum[-1])", "t_accum.append", "t_accum", "append", "t_accum[-1]", "t_accum", "-1", "s_accum.append(s_accum[-1])", "s_accum.append", "s_accum", "append", "s_accum[-1]", "s_accum", "-1", "t_accum.append(t_accum[-1] + 1)", "t_accum.append", "t_accum", "append", "t_accum[-1] + 1", "t_accum[-1]", "t_accum", "-1", "1", "if ch == 'T':\n t_up = max(t_up, t_accum[-1] - s_accum[-1])\n ", "ch == 'T'", "ch", "'T'", "t_up = max(t_up, t_accum[-1] - s_accum[-1])", "t_up", "max(t_up, t_accum[-1] - s_accum[-1])", "max", "t_up", "t_accum[-1] - s_accum[-1]", "t_accum[-1]", "t_accum", "-1", "s_accum[-1]", "s_accum", "-1", "ans = 2 * t_up", "ans", "2 * t_up", "2", "t_up", "print(ans)", "print", "ans", "agc005_a()", "agc005_a", "def agc005_a():\n x = str(input())\n s_accum = [0]\n t_accum = [0]\n t_up = 0\n for ch in x:\n # SとTの出現回数の累積和\n if ch == 'S':\n s_accum.append(s_accum[-1] + 1)\n t_accum.append(t_accum[-1])\n else:\n s_accum.append(s_accum[-1])\n t_accum.append(t_accum[-1] + 1)\n # Tの左側にいるSとの差分が、残るTの数で、プラスの値ならTが先頭に残る\n if ch == 'T':\n t_up = max(t_up, t_accum[-1] - s_accum[-1])\n ans = 2 * t_up\n print(ans)", "def agc005_a():\n x = str(input())\n s_accum = [0]\n t_accum = [0]\n t_up = 0\n for ch in x:\n # SとTの出現回数の累積和\n if ch == 'S':\n s_accum.append(s_accum[-1] + 1)\n t_accum.append(t_accum[-1])\n else:\n s_accum.append(s_accum[-1])\n t_accum.append(t_accum[-1] + 1)\n # Tの左側にいるSとの差分が、残るTの数で、プラスの値ならTが先頭に残る\n if ch == 'T':\n t_up = max(t_up, t_accum[-1] - s_accum[-1])\n ans = 2 * t_up\n print(ans)", "agc005_a" ]
def agc005_a(): x = str(input()) s_accum = [0] t_accum = [0] t_up = 0 for ch in x: # SとTの出現回数の累積和 if ch == 'S': s_accum.append(s_accum[-1] + 1) t_accum.append(t_accum[-1]) else: s_accum.append(s_accum[-1]) t_accum.append(t_accum[-1] + 1) # Tの左側にいるSとの差分が、残るTの数で、プラスの値ならTが先頭に残る if ch == 'T': t_up = max(t_up, t_accum[-1] - s_accum[-1]) ans = 2 * t_up print(ans) agc005_a()
[ 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, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 45, 2 ], [ 39, 6 ], [ 48, 8 ], [ 12, 11 ], [ 46, 11 ], [ 11, 15 ], [ 51, 18 ], [ 40, 22 ], [ 37, 22 ], [ 52, 22 ], [ 42, 25 ], [ 36, 28 ], [ 37, 33 ], [ 52, 33 ], [ 40, 33 ], [ 43, 34 ], [ 49, 34 ], [ 36, 37 ], [ 39, 40 ], [ 42, 43 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "X = input()\ns, t = 0, 0\nfor i in X:\n if i=='S':\n s += 1\n else:\n if s==0:\n t += 1\n else:\n s-= 1\nprint(s+t)", "X = input()", "X", "input()", "input", "s, t = 0, 0", "s", "0", "t", "0", "for i in X:\n if i=='S':\n s += 1\n else:\n if s==0:\n t += 1\n else:\n s-= 1", "i", "X", "if i=='S':\n s += 1\n else:\n if s==0:\n t += 1\n else:\n s-= 1", "i=='S'", "i", "'S'", "s += 1", "s", "1", "if s==0:\n t += 1\n else:\n s-= 1", "s==0", "s", "0", "t += 1", "t", "1", "s-= 1", "s", "1", "print(s+t)", "print", "s+t", "s", "t", "s-= 1", "1", "s", "s, t = 0, 0", "0", "s", "t += 1", "1", "t", "X = input()", "input()", "X", "t = 0, 0", "0", "t", "s += 1", "1", "s" ]
X = input() s, t = 0, 0 for i in X: if i=='S': s += 1 else: if s==0: t += 1 else: s-= 1 print(s+t)
[ 7, 15, 13, 12, 13, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 2, 39, 17, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 2, 13, 17, 14, 2, 18, 13, 18, 13, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 9, 8 ], [ 59, 12 ], [ 15, 14 ], [ 59, 26 ], [ 30, 29 ], [ 33, 32 ], [ 8, 37 ], [ 14, 42 ], [ 14, 44 ], [ 32, 45 ], [ 32, 46 ], [ 49, 48 ], [ 48, 53 ], [ 29, 53 ], [ 62, 56 ] ]
[ "import sys\ndef input(): return sys.stdin.readline().strip()\n\ndef resolve():\n n=int(input())\n l=[0]+list(map(int,input().split()))\n cnt=0\n for i in range(1,n+1):\n if l[l[i]]==i:\n cnt+=1\n print(cnt//2)\nresolve()", "import sys", "sys", "def input(): return sys.stdin.readline().strip()", "input", "def resolve():\n n=int(input())\n l=[0]+list(map(int,input().split()))\n cnt=0\n for i in range(1,n+1):\n if l[l[i]]==i:\n cnt+=1\n print(cnt//2)", "resolve", "n=int(input())", "n", "int(input())", "int", "input()", "input", "l=[0]+list(map(int,input().split()))", "l", "[0]+list(map(int,input().split()))", "[0]", "0", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "cnt=0", "cnt", "0", "for i in range(1,n+1):\n if l[l[i]]==i:\n cnt+=1\n ", "i", "range(1,n+1)", "range", "1", "n+1", "n", "1", "if l[l[i]]==i:\n cnt+=1\n ", "l[l[i]]==i", "l[l[i]]", "l", "l[i]", "l", "i", "i", "cnt+=1", "cnt", "1", "print(cnt//2)", "print", "cnt//2", "cnt", "2", "resolve()", "resolve", "def input(): return sys.stdin.readline().strip()", "def input(): return sys.stdin.readline().strip()", "input", "def resolve():\n n=int(input())\n l=[0]+list(map(int,input().split()))\n cnt=0\n for i in range(1,n+1):\n if l[l[i]]==i:\n cnt+=1\n print(cnt//2)", "def resolve():\n n=int(input())\n l=[0]+list(map(int,input().split()))\n cnt=0\n for i in range(1,n+1):\n if l[l[i]]==i:\n cnt+=1\n print(cnt//2)", "resolve" ]
import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) l=[0]+list(map(int,input().split())) cnt=0 for i in range(1,n+1): if l[l[i]]==i: cnt+=1 print(cnt//2) resolve()
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 2, 4, 18, 13, 13, 2, 18, 13, 2, 13, 17, 2, 4, 18, 13, 13, 13, 17, 17, 10, 4, 13, 10, 4, 13 ]
[ [ 47, 4 ], [ 50, 10 ], [ 51, 34 ], [ 51, 36 ], [ 48, 43 ], [ 47, 48 ], [ 50, 51 ] ]
[ "import numpy as np\n\nN = int(input())\nA = np.array(tuple(map(int, input().split())))\nprint(np.count_nonzero(A[A - 1] == np.arange(N) + 1) // 2)", "import numpy as np", "numpy", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = np.array(tuple(map(int, input().split())))", "A", "np.array(tuple(map(int, input().split())))", "np.array", "np", "array", "tuple(map(int, input().split()))", "tuple", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(np.count_nonzero(A[A - 1] == np.arange(N) + 1) // 2)", "print", "np.count_nonzero(A[A - 1] == np.arange(N) + 1) // 2", "np.count_nonzero(A[A - 1] == np.arange(N) + 1)", "np.count_nonzero", "np", "count_nonzero", "A[A - 1] == np.arange(N) + 1", "A[A - 1]", "A", "A - 1", "A", "1", "np.arange(N) + 1", "np.arange(N)", "np.arange", "np", "arange", "N", "1", "2", "N = int(input())", "int(input())", "N", "A = np.array(tuple(map(int, input().split())))", "np.array(tuple(map(int, input().split())))", "A" ]
import numpy as np N = int(input()) A = np.array(tuple(map(int, input().split()))) print(np.count_nonzero(A[A - 1] == np.arange(N) + 1) // 2)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 28, 13, 4, 13, 13, 0, 13, 4, 13, 4, 13, 39, 2, 13, 17, 18, 13, 13, 4, 18, 13, 13, 13, 4, 13, 2, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 60, 2 ], [ 54, 8 ], [ 63, 20 ], [ 25, 24 ], [ 61, 27 ], [ 57, 29 ], [ 24, 36 ], [ 55, 39 ], [ 24, 40 ], [ 64, 43 ], [ 58, 45 ], [ 61, 49 ], [ 64, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "n = int(input())\n\nL = list(map(int,input().split()))\n\nli = set()\n\nfor i in range(n):\n a = tuple(sorted([i+1,L[i]]))\n li.add(a)\nprint(n-len(li))", "n = int(input())", "n", "int(input())", "int", "input()", "input", "L = list(map(int,input().split()))", "L", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "li = set()", "li", "set()", "set", "for i in range(n):\n a = tuple(sorted([i+1,L[i]]))\n li.add(a)", "i", "range(n)", "range", "n", "a = tuple(sorted([i+1,L[i]]))", "a", "tuple(sorted([i+1,L[i]]))", "tuple", "sorted([i+1,L[i]])", "sorted", "[i+1,L[i]]", "i+1", "i", "1", "L[i]", "L", "i", "li.add(a)", "li.add", "li", "add", "a", "print(n-len(li))", "print", "n-len(li)", "n", "len(li)", "len", "li", "L = list(map(int,input().split()))", "list(map(int,input().split()))", "L", "a = tuple(sorted([i+1,L[i]]))", "tuple(sorted([i+1,L[i]]))", "a", "n = int(input())", "int(input())", "n", "li = set()", "set()", "li" ]
n = int(input()) L = list(map(int,input().split())) li = set() for i in range(n): a = tuple(sorted([i+1,L[i]])) li.add(a) print(n-len(li))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 15, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 18, 13, 2, 18, 13, 13, 17, 17, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 18, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13 ]
[ [ 58, 4 ], [ 61, 12 ], [ 59, 16 ], [ 64, 18 ], [ 59, 27 ], [ 67, 30 ], [ 34, 33 ], [ 62, 36 ], [ 65, 41 ], [ 65, 44 ], [ 33, 45 ], [ 33, 48 ], [ 70, 50 ], [ 71, 55 ], [ 68, 55 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "import sys\ninput = sys.stdin.readline\nfrom collections import *\n\nN = int(input())\na = list(map(int, input().split()))\nans = 0\n\nfor i in range(N):\n if a[a[i]-1]-1==i:\n ans += 1\n\nprint(ans//2)", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "from collections import *", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 0", "ans", "0", "for i in range(N):\n if a[a[i]-1]-1==i:\n ans += 1", "i", "range(N)", "range", "N", "if a[a[i]-1]-1==i:\n ans += 1", "a[a[i]-1]-1==i", "a[a[i]-1]-1", "a[a[i]-1]", "a", "a[i]-1", "a[i]", "a", "i", "1", "1", "i", "ans += 1", "ans", "1", "print(ans//2)", "print", "ans//2", "ans", "2", "input = sys.stdin.readline", "sys.stdin.readline", "input", "N = int(input())", "int(input())", "N", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "ans = 0", "0", "ans", "ans += 1", "1", "ans" ]
import sys input = sys.stdin.readline from collections import * N = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(N): if a[a[i]-1]-1==i: ans += 1 print(ans//2)
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 39, 28, 13, 4, 13, 13, 14, 2, 18, 13, 13, 2, 13, 17, 14, 2, 18, 13, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 39, 2, 18, 13, 13, 17, 13, 4, 18, 13, 13, 4, 13, 13, 4, 13, 2, 4, 13, 13, 17, 10, 39, 13, 10, 39, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 80, 2 ], [ 10, 9 ], [ 9, 18 ], [ 83, 20 ], [ 77, 23 ], [ 27, 26 ], [ 81, 29 ], [ 84, 33 ], [ 26, 34 ], [ 26, 36 ], [ 84, 41 ], [ 84, 44 ], [ 26, 45 ], [ 26, 48 ], [ 74, 51 ], [ 84, 55 ], [ 26, 56 ], [ 78, 61 ], [ 75, 65 ], [ 78, 71 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ] ]
[ "n=int(input())\na=[int(x) for x in input().split()]\nb=[]\nfor i in range(n):\n if a[i]==i+1:continue\n if a[a[i]-1]==i+1:\n t=[a[i]-1,i]\n b.append(sorted(t))\n# print(b)\nprint(len(b)//2)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "a=[int(x) for x in input().split()]", "a", "[int(x) for x in input().split()]", "b=[]", "b", "[]", "for i in range(n):\n if a[i]==i+1:continue\n if a[a[i]-1]==i+1:\n t=[a[i]-1,i]\n b.append(sorted(t))\n# print(b)", "i", "range(n)", "range", "n", "if a[i]==i+1:continue\n ", "a[i]==i+1", "a[i]", "a", "i", "i+1", "i", "1", "if a[a[i]-1]==i+1:\n t=[a[i]-1,i]\n b.append(sorted(t))\n# print(b)", "a[a[i]-1]==i+1", "a[a[i]-1]", "a", "a[i]-1", "a[i]", "a", "i", "1", "i+1", "i", "1", "t=[a[i]-1,i]", "t", "[a[i]-1,i]", "a[i]-1", "a[i]", "a", "i", "1", "i", "b.append(sorted(t))", "b.append", "b", "append", "sorted(t)", "sorted", "t", "print(len(b)//2)", "print", "len(b)//2", "len(b)", "len", "b", "2", "t=[a[i]-1,i]", "[a[i]-1,i]", "t", "b=[]", "[]", "b", "n=int(input())", "int(input())", "n", "a=[int(x) for x in input().split()]", "[int(x) for x in input().split()]", "a" ]
n=int(input()) a=[int(x) for x in input().split()] b=[] for i in range(n): if a[i]==i+1:continue if a[a[i]-1]==i+1: t=[a[i]-1,i] b.append(sorted(t)) # print(b) print(len(b)//2)
[ 7, 15, 13, 15, 13, 15, 13, 15, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 0, 13, 18, 18, 18, 13, 13, 13, 13, 12, 13, 0, 13, 17, 28, 13, 13, 4, 13, 13, 14, 2, 2, 13, 17, 18, 13, 2, 13, 17, 0, 13, 17, 29, 2, 13, 17, 23, 13, 23, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 18, 13, 13, 4, 18, 4, 13, 13, 18, 13, 13, 4, 13, 4, 13, 13, 13, 10, 18, 13, 10, 18, 13, 10, 4, 13, 10, 12, 13, 10, 18, 13, 10, 4, 13 ]
[ [ 97, 9 ], [ 106, 18 ], [ 94, 27 ], [ 39, 38 ], [ 66, 45 ], [ 66, 52 ], [ 58, 57 ], [ 57, 61 ], [ 38, 61 ], [ 64, 64 ], [ 66, 66 ], [ 100, 68 ], [ 107, 72 ], [ 109, 74 ], [ 107, 82 ], [ 104, 90 ], [ 101, 91 ], [ 110, 92 ], [ 94, 95 ], [ 97, 98 ], [ 100, 101 ], [ 106, 107 ], [ 109, 110 ] ]
[ "import sys\nimport numpy as np\nimport numba\nfrom numba import jit\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\ndef main(n, a):\n cnt = 0\n for i, j in enumerate(a):\n if i+1 == a[j-1]:\n cnt+=1\n return cnt//2\n\nn = int(readline())\na = np.array(readline().split(), np.int64)\nprint(main(n,a))", "import sys", "sys", "import numpy as np", "numpy", "import numba", "numba", "from numba import jit", "read = sys.stdin.buffer.read", "read", "sys.stdin.buffer.read", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "read", "readline = sys.stdin.buffer.readline", "readline", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "readlines = sys.stdin.buffer.readlines", "readlines", "sys.stdin.buffer.readlines", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readlines", "def main(n, a):\n cnt = 0\n for i, j in enumerate(a):\n if i+1 == a[j-1]:\n cnt+=1\n return cnt//2", "main", "cnt = 0", "cnt", "0", "for i, j in enumerate(a):\n if i+1 == a[j-1]:\n cnt+=1\n ", "i", "j", "enumerate(a)", "enumerate", "a", "if i+1 == a[j-1]:\n cnt+=1\n ", "i+1 == a[j-1]", "i+1", "i", "1", "a[j-1]", "a", "j-1", "j", "1", "cnt+=1", "cnt", "1", "return cnt//2", "cnt//2", "cnt", "2", "n", "n", "a", "a", "n = int(readline())", "n", "int(readline())", "int", "readline()", "readline", "a = np.array(readline().split(), np.int64)", "a", "np.array(readline().split(), np.int64)", "np.array", "np", "array", "readline().split()", "().split", "()", "readline", "split", "np.int64", "np", "int64", "print(main(n,a))", "print", "main(n,a)", "main", "n", "a", "readlines = sys.stdin.buffer.readlines", "sys.stdin.buffer.readlines", "readlines", "read = sys.stdin.buffer.read", "sys.stdin.buffer.read", "read", "n = int(readline())", "int(readline())", "n", "def main(n, a):\n cnt = 0\n for i, j in enumerate(a):\n if i+1 == a[j-1]:\n cnt+=1\n return cnt//2", "def main(n, a):\n cnt = 0\n for i, j in enumerate(a):\n if i+1 == a[j-1]:\n cnt+=1\n return cnt//2", "main", "readline = sys.stdin.buffer.readline", "sys.stdin.buffer.readline", "readline", "a = np.array(readline().split(), np.int64)", "np.array(readline().split(), np.int64)", "a" ]
import sys import numpy as np import numba from numba import jit read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def main(n, a): cnt = 0 for i, j in enumerate(a): if i+1 == a[j-1]: cnt+=1 return cnt//2 n = int(readline()) a = np.array(readline().split(), np.int64) print(main(n,a))
[ 7, 15, 15, 15, 15, 13, 15, 13, 15, 13, 41, 28, 13, 4, 18, 4, 18, 18, 18, 13, 13, 13, 13, 13, 4, 4, 13, 13, 12, 13, 12, 13, 41, 28, 13, 4, 18, 4, 18, 18, 13, 13, 13, 13, 4, 4, 13, 13, 12, 13, 12, 13, 0, 13, 4, 13, 4, 18, 18, 13, 13, 13, 14, 2, 18, 13, 17, 17, 29, 18, 13, 39, 17, 29, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 29, 13, 23, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 29, 13, 23, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 29, 13, 23, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 29, 13, 23, 13, 4, 18, 13, 13, 17, 0, 13, 17, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 28, 13, 4, 13, 13, 0, 18, 13, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 18, 13, 13, 13, 2, 18, 13, 13, 13, 4, 13, 13, 29, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 13, 12 ], [ 12, 27 ], [ 35, 34 ], [ 34, 47 ], [ 54, 53 ], [ 53, 65 ], [ 53, 70 ], [ 53, 74 ], [ 80, 79 ], [ 89, 82 ], [ 222, 85 ], [ 89, 89 ], [ 95, 94 ], [ 104, 97 ], [ 216, 100 ], [ 104, 104 ], [ 110, 109 ], [ 119, 112 ], [ 198, 115 ], [ 119, 119 ], [ 125, 124 ], [ 134, 127 ], [ 207, 130 ], [ 134, 134 ], [ 212, 141 ], [ 147, 146 ], [ 222, 148 ], [ 151, 150 ], [ 216, 152 ], [ 155, 154 ], [ 146, 157 ], [ 162, 159 ], [ 150, 160 ], [ 154, 161 ], [ 165, 164 ], [ 168, 167 ], [ 146, 170 ], [ 173, 172 ], [ 150, 176 ], [ 159, 177 ], [ 150, 178 ], [ 167, 179 ], [ 167, 180 ], [ 159, 182 ], [ 150, 183 ], [ 167, 184 ], [ 167, 185 ], [ 172, 188 ], [ 164, 188 ], [ 210, 195 ], [ 212, 213 ] ]
[ "#!usr/bin/env python3\nfrom collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom itertools import permutations, accumulate\nimport sys\nimport math\nimport bisect\ndef LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS():return [list(x) for x in sys.stdin.readline().split()]\ndef S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res\ndef IR(n):\n return [I() for i in range(n)]\ndef LIR(n):\n return [LI() for i in range(n)]\ndef SR(n):\n return [S() for i in range(n)]\ndef LSR(n):\n return [LS() for i in range(n)]\n\nsys.setrecursionlimit(1000000)\nmod = 1000000007\n\ndef solve():\n n = I()\n a = LI()\n for i in range(n):\n a[i] -= 1\n ans = 0\n for i in range(n):\n ans += (a[a[i]] == i)&(a[i] > i)\n print(ans)\n return\n\n#Solve\nif __name__ == \"__main__\":\n solve()", "from collections import defaultdict, deque", "from heapq import heappush, heappop", "from itertools import permutations, accumulate", "import sys", "sys", "import math", "math", "import bisect", "bisect", "int(x) for x in sys.stdin.buffer.readline().split()", "for x in sys.stdin.buffer.readline().split()", "x", "sys.stdin.buffer.readline().split()", "sys.stdin.buffer.readline().split", "sys.stdin.buffer.readline()", "sys.stdin.buffer.readline", "sys.stdin.buffer", "sys.stdin", "sys", "stdin", "buffer", "readline", "split", "for x in sys.stdin.buffer.readline().split()", "int(x)", "int", "x", "def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]", "LI", "def I(): return int(sys.stdin.buffer.readline())", "I", "list(x) for x in sys.stdin.readline().split()", "for x in sys.stdin.readline().split()", "x", "sys.stdin.readline().split()", "sys.stdin.readline().split", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "split", "for x in sys.stdin.readline().split()", "list(x)", "list", "x", "def LS():return [list(x) for x in sys.stdin.readline().split()]", "LS", "def S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res", "S", "res = list(sys.stdin.readline())", "res", "list(sys.stdin.readline())", "list", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "if res[-1] == \"\\n\":\n return res[:-1]\n ", "res[-1] == \"\\n\"", "res[-1]", "res", "-1", "\"\\n\"", "return res[:-1]", "res[:-1]", "res", ":-1", "-1", "return res", "res", "def IR(n):\n return [I() for i in range(n)]", "IR", "I() for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "I()", "I", "return [I() for i in range(n)]", "[I() for i in range(n)]", "n", "n", "def LIR(n):\n return [LI() for i in range(n)]", "LIR", "LI() for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "LI()", "LI", "return [LI() for i in range(n)]", "[LI() for i in range(n)]", "n", "n", "def SR(n):\n return [S() for i in range(n)]", "SR", "S() for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "S()", "S", "return [S() for i in range(n)]", "[S() for i in range(n)]", "n", "n", "def LSR(n):\n return [LS() for i in range(n)]", "LSR", "LS() for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "LS()", "LS", "return [LS() for i in range(n)]", "[LS() for i in range(n)]", "n", "n", "sys.setrecursionlimit(1000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "1000000", "mod = 1000000007", "mod", "1000000007", "def solve():\n n = I()\n a = LI()\n for i in range(n):\n a[i] -= 1\n ans = 0\n for i in range(n):\n ans += (a[a[i]] == i)&(a[i] > i)\n print(ans)\n return\n\n#Solve", "solve", "n = I()", "n", "I()", "I", "a = LI()", "a", "LI()", "LI", "for i in range(n):\n a[i] -= 1\n ", "i", "range(n)", "range", "n", "a[i] -= 1", "a[i]", "a", "i", "1", "ans = 0", "ans", "0", "for i in range(n):\n ans += (a[a[i]] == i)&(a[i] > i)\n ", "i", "range(n)", "range", "n", "ans += (a[a[i]] == i)&(a[i] > i)", "ans", "(a[a[i]] == i)&(a[i] > i)", "a[a[i]] == i", "a[a[i]]", "a", "a[i]", "a", "i", "i", "a[i] > i", "a[i]", "a", "i", "i", "print(ans)", "print", "ans", "return", "if __name__ == \"__main__\":\n solve()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "solve()", "solve", "def S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res", "def S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res", "S", "def SR(n):\n return [S() for i in range(n)]", "def SR(n):\n return [S() for i in range(n)]", "SR", "def LSR(n):\n return [LS() for i in range(n)]", "def LSR(n):\n return [LS() for i in range(n)]", "LSR", "def LS():return [list(x) for x in sys.stdin.readline().split()]", "def LS():return [list(x) for x in sys.stdin.readline().split()]", "LS", "def solve():\n n = I()\n a = LI()\n for i in range(n):\n a[i] -= 1\n ans = 0\n for i in range(n):\n ans += (a[a[i]] == i)&(a[i] > i)\n print(ans)\n return\n\n#Solve", "def solve():\n n = I()\n a = LI()\n for i in range(n):\n a[i] -= 1\n ans = 0\n for i in range(n):\n ans += (a[a[i]] == i)&(a[i] > i)\n print(ans)\n return\n\n#Solve", "solve", "mod = 1000000007", "1000000007", "mod", "def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]", "def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]", "LI", "def LIR(n):\n return [LI() for i in range(n)]", "def LIR(n):\n return [LI() for i in range(n)]", "LIR", "def I(): return int(sys.stdin.buffer.readline())", "def I(): return int(sys.stdin.buffer.readline())", "I", "def IR(n):\n return [I() for i in range(n)]", "def IR(n):\n return [I() for i in range(n)]", "IR" ]
#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) def LS():return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 def solve(): n = I() a = LI() for i in range(n): a[i] -= 1 ans = 0 for i in range(n): ans += (a[a[i]] == i)&(a[i] > i) print(ans) return #Solve if __name__ == "__main__": solve()
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 17, 0, 13, 17, 28, 13, 13, 4, 13, 13, 14, 2, 18, 13, 2, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 51, 2 ], [ 54, 8 ], [ 48, 21 ], [ 55, 28 ], [ 55, 32 ], [ 57, 40 ], [ 58, 45 ], [ 49, 45 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "N=int(input())\nA=list(map(int,input().split(' ')))\nans = 0\nfor n,i in enumerate(A):\n if A[i-1]==n+1:\n ans += 1\nprint(ans//2)", "N=int(input())", "N", "int(input())", "int", "input()", "input", "A=list(map(int,input().split(' ')))", "A", "list(map(int,input().split(' ')))", "list", "map(int,input().split(' '))", "map", "int", "input().split(' ')", "().split", "()", "input", "split", "' '", "ans = 0", "ans", "0", "for n,i in enumerate(A):\n if A[i-1]==n+1:\n ans += 1", "n", "i", "enumerate(A)", "enumerate", "A", "if A[i-1]==n+1:\n ans += 1", "A[i-1]==n+1", "A[i-1]", "A", "i-1", "i", "1", "n+1", "n", "1", "ans += 1", "ans", "1", "print(ans//2)", "print", "ans//2", "ans", "2", "ans = 0", "0", "ans", "N=int(input())", "int(input())", "N", "A=list(map(int,input().split(' ')))", "list(map(int,input().split(' ')))", "A", "ans += 1", "1", "ans" ]
N=int(input()) A=list(map(int,input().split(' '))) ans = 0 for n,i in enumerate(A): if A[i-1]==n+1: ans += 1 print(ans//2)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 2, 18, 13, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 4, 13, 2, 13, 17, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 50, 2 ], [ 56, 8 ], [ 53, 20 ], [ 24, 23 ], [ 51, 26 ], [ 57, 30 ], [ 57, 33 ], [ 23, 34 ], [ 23, 37 ], [ 59, 40 ], [ 60, 47 ], [ 54, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "N = int(input())\na = list(map(int,input().split()))\n\nans = 0\n\nfor i in range(N):\n if a[a[i]-1] == i+1:\n ans += 1\nprint(int(ans/2))", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 0", "ans", "0", "for i in range(N):\n if a[a[i]-1] == i+1:\n ans += 1", "i", "range(N)", "range", "N", "if a[a[i]-1] == i+1:\n ans += 1", "a[a[i]-1] == i+1", "a[a[i]-1]", "a", "a[i]-1", "a[i]", "a", "i", "1", "i+1", "i", "1", "ans += 1", "ans", "1", "print(int(ans/2))", "print", "int(ans/2)", "int", "ans/2", "ans", "2", "N = int(input())", "int(input())", "N", "ans = 0", "0", "ans", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans += 1", "1", "ans" ]
N = int(input()) a = list(map(int,input().split())) ans = 0 for i in range(N): if a[a[i]-1] == i+1: ans += 1 print(int(ans/2))
[ 7, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 12, 2, 4, 13, 13, 17, 23, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 18, 13, 18, 13, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 5, 4 ], [ 11, 10 ], [ 29, 28 ], [ 32, 31 ], [ 4, 34 ], [ 10, 38 ], [ 10, 40 ], [ 31, 41 ], [ 31, 42 ], [ 45, 44 ], [ 44, 49 ], [ 28, 49 ], [ 59, 56 ] ]
[ "def main():\n N = int( input())\n A = list( map( lambda x: int(x)-1, input().split()))\n ans = 0\n for i in range(N):\n if A[A[i]] == i:\n ans += 1\n print(ans//2)\nif __name__ == '__main__':\n main()", "def main():\n N = int( input())\n A = list( map( lambda x: int(x)-1, input().split()))\n ans = 0\n for i in range(N):\n if A[A[i]] == i:\n ans += 1\n print(ans//2)", "main", "N = int( input())", "N", "int( input())", "int", "input()", "input", "A = list( map( lambda x: int(x)-1, input().split()))", "A", "list( map( lambda x: int(x)-1, input().split()))", "list", "map( lambda x: int(x)-1, input().split())", "map", "lambda x: int(x)-1", "int(x)-1", "int(x)", "int", "x", "1", "x", "input().split()", "().split", "()", "input", "split", "ans = 0", "ans", "0", "for i in range(N):\n if A[A[i]] == i:\n ans += 1\n ", "i", "range(N)", "range", "N", "if A[A[i]] == i:\n ans += 1\n ", "A[A[i]] == i", "A[A[i]]", "A", "A[i]", "A", "i", "i", "ans += 1", "ans", "1", "print(ans//2)", "print", "ans//2", "ans", "2", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def main():\n N = int( input())\n A = list( map( lambda x: int(x)-1, input().split()))\n ans = 0\n for i in range(N):\n if A[A[i]] == i:\n ans += 1\n print(ans//2)", "def main():\n N = int( input())\n A = list( map( lambda x: int(x)-1, input().split()))\n ans = 0\n for i in range(N):\n if A[A[i]] == i:\n ans += 1\n print(ans//2)", "main" ]
def main(): N = int( input()) A = list( map( lambda x: int(x)-1, input().split())) ans = 0 for i in range(N): if A[A[i]] == i: ans += 1 print(ans//2) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 18, 13, 13, 17, 13, 14, 2, 2, 18, 13, 2, 18, 13, 13, 17, 17, 13, 0, 13, 17, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 57, 2 ], [ 63, 8 ], [ 60, 20 ], [ 24, 23 ], [ 58, 26 ], [ 64, 31 ], [ 23, 32 ], [ 23, 34 ], [ 64, 39 ], [ 64, 42 ], [ 23, 43 ], [ 23, 46 ], [ 54, 48 ], [ 55, 52 ], [ 61, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "n = int(input())\nl = list(map(int, input().split())) \ncnt = 0\nfor i in range(n): \n if l[i]-1 > i:\n if( l[l[i]-1]-1 == i):\n cnt+=1\nprint(cnt)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "l = list(map(int, input().split()))", "l", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "cnt = 0", "cnt", "0", "for i in range(n): \n if l[i]-1 > i:\n if( l[l[i]-1]-1 == i):\n cnt+=1", "i", "range(n)", "range", "n", "if l[i]-1 > i:\n if( l[l[i]-1]-1 == i):\n cnt+=1", "l[i]-1 > i", "l[i]-1", "l[i]", "l", "i", "1", "i", "if( l[l[i]-1]-1 == i):\n cnt+=1", "l[l[i]-1]-1 == i", "l[l[i]-1]-1", "l[l[i]-1]", "l", "l[i]-1", "l[i]", "l", "i", "1", "1", "i", "cnt+=1", "cnt", "1", "print(cnt)", "print", "cnt", "cnt+=1", "1", "cnt", "n = int(input())", "int(input())", "n", "cnt = 0", "0", "cnt", "l = list(map(int, input().split()))", "list(map(int, input().split()))", "l" ]
n = int(input()) l = list(map(int, input().split())) cnt = 0 for i in range(n): if l[i]-1 > i: if( l[l[i]-1]-1 == i): cnt+=1 print(cnt)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 41, 28, 13, 4, 13, 13, 4, 39, 0, 13, 13, 28, 13, 4, 13, 13, 4, 18, 18, 13, 2, 18, 13, 13, 17, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 14, 2, 2, 18, 13, 13, 17, 18, 13, 13, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 76, 2 ], [ 85, 8 ], [ 22, 21 ], [ 77, 24 ], [ 79, 28 ], [ 32, 31 ], [ 77, 34 ], [ 80, 38 ], [ 86, 41 ], [ 31, 42 ], [ 31, 45 ], [ 73, 47 ], [ 51, 50 ], [ 77, 53 ], [ 86, 58 ], [ 50, 59 ], [ 80, 62 ], [ 50, 63 ], [ 82, 65 ], [ 83, 70 ], [ 74, 70 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ] ]
[ "N = int(input())\na = list(map(int, input().split()))\nL = [[] for _ in range(N)]\nfor i in range(N):\n L[a[i]-1].append(i)\ncnt = 0\nfor i in range(N):\n if a[i]-1 in L[i]:\n cnt += 1\nprint(cnt//2)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "[] for _ in range(N)", "for _ in range(N)", "_", "range(N)", "range", "N", "for _ in range(N)", "[]", "L = [[] for _ in range(N)]", "L", "[[] for _ in range(N)]", "for i in range(N):\n L[a[i]-1].append(i)", "i", "range(N)", "range", "N", "L[a[i]-1].append(i)", "[a[i]-1].append", "[a[i]-1]", "L", "a[i]-1", "a[i]", "a", "i", "1", "append", "i", "cnt = 0", "cnt", "0", "for i in range(N):\n if a[i]-1 in L[i]:\n cnt += 1", "i", "range(N)", "range", "N", "if a[i]-1 in L[i]:\n cnt += 1", "a[i]-1 in L[i]", "a[i]-1", "a[i]", "a", "i", "1", "L[i]", "L", "i", "cnt += 1", "cnt", "1", "print(cnt//2)", "print", "cnt//2", "cnt", "2", "cnt = 0", "0", "cnt", "N = int(input())", "int(input())", "N", "L = [[] for _ in range(N)]", "[[] for _ in range(N)]", "L", "cnt += 1", "1", "cnt", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a" ]
N = int(input()) a = list(map(int, input().split())) L = [[] for _ in range(N)] for i in range(N): L[a[i]-1].append(i) cnt = 0 for i in range(N): if a[i]-1 in L[i]: cnt += 1 print(cnt//2)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 17, 13, 13, 31, 13, 0, 13, 17, 28, 13, 13, 4, 13, 13, 14, 2, 2, 13, 17, 18, 13, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 51, 2 ], [ 51, 15 ], [ 45, 18 ], [ 48, 37 ], [ 49, 42 ], [ 46, 42 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ] ]
[ "N,*A = map(int,open(0).read().split())\ncnt=0\nfor i,a in enumerate(A):\n if i+1 == A[a-1]:\n cnt+=1\nprint(cnt//2)", "N,*A = map(int,open(0).read().split())", "N", "map(int,open(0).read().split())", "map", "int", "open(0).read().split()", "(0).read().split", "(0).read()", "(0).read", "(0)", "open", "0", "read", "split", "*A", "A", "cnt=0", "cnt", "0", "for i,a in enumerate(A):\n if i+1 == A[a-1]:\n cnt+=1", "i", "a", "enumerate(A)", "enumerate", "A", "if i+1 == A[a-1]:\n cnt+=1", "i+1 == A[a-1]", "i+1", "i", "1", "A[a-1]", "A", "a-1", "a", "1", "cnt+=1", "cnt", "1", "print(cnt//2)", "print", "cnt//2", "cnt", "2", "cnt=0", "0", "cnt", "cnt+=1", "1", "cnt", "N,*A = map(int,open(0).read().split())", "map(int,open(0).read().split())", "N" ]
N,*A = map(int,open(0).read().split()) cnt=0 for i,a in enumerate(A): if i+1 == A[a-1]: cnt+=1 print(cnt//2)
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 17, 28, 13, 13, 4, 13, 13, 14, 2, 18, 13, 2, 13, 17, 2, 13, 17, 0, 13, 17, 4, 13, 2, 13, 17, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13 ]
[ [ 53, 2 ], [ 10, 9 ], [ 9, 18 ], [ 59, 20 ], [ 56, 23 ], [ 60, 30 ], [ 60, 34 ], [ 50, 42 ], [ 51, 47 ], [ 57, 47 ], [ 50, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ] ]
[ "#!/usr/bin/env python3\n\nn = int(input())\na = [int(x) for x in input().split()]\nc = 0\nfor i, ax in enumerate(a):\n if a[ax - 1] == i + 1:\n c += 1\nprint(c // 2)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "a = [int(x) for x in input().split()]", "a", "[int(x) for x in input().split()]", "c = 0", "c", "0", "for i, ax in enumerate(a):\n if a[ax - 1] == i + 1:\n c += 1", "i", "ax", "enumerate(a)", "enumerate", "a", "if a[ax - 1] == i + 1:\n c += 1", "a[ax - 1] == i + 1", "a[ax - 1]", "a", "ax - 1", "ax", "1", "i + 1", "i", "1", "c += 1", "c", "1", "print(c // 2)", "print", "c // 2", "c", "2", "c += 1", "1", "c", "n = int(input())", "int(input())", "n", "c = 0", "0", "c", "a = [int(x) for x in input().split()]", "[int(x) for x in input().split()]", "a" ]
#!/usr/bin/env python3 n = int(input()) a = [int(x) for x in input().split()] c = 0 for i, ax in enumerate(a): if a[ax - 1] == i + 1: c += 1 print(c // 2)