{"problem":{"name":"STring","description":{"content":"We have a string $X$, which has an even number of characters. Half the characters are `S`, and the other half are `T`. Takahashi, who hates the string `ST`, will perform the following operation $10^{1","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc005_a"},"statements":[{"statement_type":"Markdown","content":"We have a string $X$, which has an even number of characters. Half the characters are `S`, and the other half are `T`.\nTakahashi, who hates the string `ST`, will perform the following operation $10^{10000}$ times:\n\n*   Among the occurrences of `ST` in $X$ as (contiguous) substrings, remove the leftmost one. If there is no occurrence, do nothing.\n\nFind the eventual length of $X$.\n\n## Constraints\n\n*   $2 ≦ |X| ≦ 200,000$\n*   The length of $X$ is even.\n*   Half the characters in $X$ are `S`, and the other half are `T`.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$X$\n\n## Partial Scores\n\n*   In test cases worth $200$ points, $|X| ≦ 200$.\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc005_a","tags":[],"sample_group":[["TSTTSS","4\n\nIn the $1$\\-st operation, the $2$\\-nd and $3$\\-rd characters of `TSTTSS` are removed. $X$ becomes `TTSS`, and since it does not contain `ST` anymore, nothing is done in the remaining $10^{10000}-1$ operations. Thus, the answer is $4$."],["SSTTST","0\n\n$X$ will eventually become an empty string: `SSTTST` ⇒ `STST` ⇒ `ST` ⇒ \\`\\`."],["TSSTTTSS","4\n\n$X$ will become: `TSSTTTSS` ⇒ `TSTTSS` ⇒ `TTSS`."]],"created_at":"2026-03-03 11:01:14"}}