Codeforces Round 447 (Div. 2)
A
QAQ
Codeforces
800
原题
←B →
翻译中…

"QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth.

翻译中…

Now Diamond has given Bort a string consisting of only uppercase English letters of length $*n*$. There is a great number of "QAQ" in the string (Diamond is so cute!).

翻译中…

image illustration by 猫屋 https://twitter.com/nekoyaliu

翻译中…

Bort wants to know how many subsequences "QAQ" are in the string Diamond has given. Note that the letters "QAQ" don't have to be consecutive, but the order of letters should be exact.

翻译中…

Input

翻译中…

The only line contains a string of length $*n*$ ($1 ≤ *n* ≤ 100$). It's guaranteed that the string only contains uppercase English letters.

翻译中…

Output

翻译中…

Print a single integer — the number of subsequences "QAQ" in the string.

翻译中…

Note

翻译中…

In the first example there are $4$ subsequences "QAQ": "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN".

翻译中…

样例

Input #1
QAQAQYSYIOIWIN
Output #1
4
InputCopy OutputCopy
Input #2
QAQQQZZYNOIWIN
Output #2
3
InputCopy OutputCopy
题目信息
题号
894A
时间限制
1 s
内存限制
256 MB
标签
暴力
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。