{"raw_statement":[{"iden":"problem statement","content":"Snuke has $N$ strings. The $i$\\-th string is $s_i$.\nLet us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 10^{4}$\n*   $2 \\leq |s_i| \\leq 10$\n*   $s_i$ consists of uppercase English letters."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$s_1$\n$\\vdots$\n$s_N$"},{"iden":"sample input 1","content":"3\nABCA\nXBAZ\nBAD"},{"iden":"sample output 1","content":"2\n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the resulting string `ABCABADXBAZ` has two occurrences of `AB`."},{"iden":"sample input 2","content":"9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA"},{"iden":"sample output 2","content":"4"},{"iden":"sample input 3","content":"7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA"},{"iden":"sample output 3","content":"4"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}