{"problem":{"name":"Remove Substrings","description":{"content":"Given is a string $S$ of length $N$ consisting of lowercase English letters. You can do the following operation on $S$ any number of times. *   Choose its (non-empty) contiguous substring such that t","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc054_a"},"statements":[{"statement_type":"Markdown","content":"Given is a string $S$ of length $N$ consisting of lowercase English letters.\nYou can do the following operation on $S$ any number of times.\n\n*   Choose its (non-empty) contiguous substring such that the first character and the last character are different, and delete this substring.\n\nDetermine whether it is possible to make $S$ empty. If it is possible, find the minimum number of operations needed to do so.\n\n## Constraints\n\n*   $2 \\leq N \\leq 10^5$\n*   $S$ is a string of length $N$ consisting of lowercase English letters.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$S$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc054_a","tags":[],"sample_group":[["4\nabba","2\n\nWe should do as follows: `abba` → (delete `ab`) → `ba` → (delete `ba`) → an empty string."],["3\naba","\\-1"]],"created_at":"2026-03-03 11:01:14"}}