{"raw_statement":[{"iden":"problem statement","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."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 10^5$\n*   $S$ is a string of length $N$ consisting of lowercase English letters."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$S$"},{"iden":"sample input 1","content":"4\nabba"},{"iden":"sample output 1","content":"2\n\nWe should do as follows: `abba` → (delete `ab`) → `ba` → (delete `ba`) → an empty string."},{"iden":"sample input 2","content":"3\naba"},{"iden":"sample output 2","content":"\\-1"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}