{"problem":{"name":"AB Substrings","description":{"content":"Snuke has $N$ strings. The $i$\\-th string is $s_i$. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"diverta2019_c"},"statements":[{"statement_type":"Markdown","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.\n\n## Constraints\n\n*   $1 \\leq N \\leq 10^{4}$\n*   $2 \\leq |s_i| \\leq 10$\n*   $s_i$ consists of uppercase English letters.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$s_1$\n$\\vdots$\n$s_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"diverta2019_c","tags":[],"sample_group":[["3\nABCA\nXBAZ\nBAD","2\n\nFor example, if we concatenate `ABCA`, `BAD` and `XBAZ` in this order, the resulting string `ABCABADXBAZ` has two occurrences of `AB`."],["9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA","4"],["7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA","4"]],"created_at":"2026-03-03 11:01:14"}}