human
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!).

 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.

Examples

Input

QAQAQYSYIOIWIN

Output

4

Input

QAQQQZZYNOIWIN

Output

3

Note

In the first example there are 4 subsequences "QAQ": "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN", "QAQAQYSYIOIWIN".
Solve the task in PYTHON3.
 Can you provide a code to qAQ" is a word to denote an expression of crying?
assistant
#Here is code to qAQ" is a word to denote an expression of crying.

# # A. Дробь
#
# def simple(a, b):
# 	Min = min(a, b)
# 	for i in range(2, Min+1):
# 		if a % i == 0 and b % i == 0:
# 			return False
# 			break
# 	else:
# 		return True
#
# n = int(input())
#
# up = 0
# down = 1
#
#
# sum = up + down
#
#
# # while True:
# # 	if up + 1 < down and sum + 1 <= n and simple(up+1, down):
# # 		up += 1
# # 	else:
# # 		if simple(up, down+1):
# # 			down += 1
# # 		else:
# # 			down += 2
# # 			up -= 1
# #
# # 	sum = up + down
# # 	if sum == n and simple(up, down):
# # 		print(up, down)
# # 		break
#
# while True:
# 	if up + 1 == down:
# 		down += 1
#
# 		if up + down == n and not simple(up, down):
# 			while not simple(up, down):
# 				up -= 1
# 				down += 1
# 	else:
# 		if simple(up+1, down):
# 			up += 1
# 		elif simple(up, down+1):
# 			down +=1
#
# 	sum = up + down
# 	if sum == n and simple(up, down):
# 		print(up, down)
# 		break

n = tuple(input())
ans = 0
sheathQ = []
sheathA = []

for i in range(len(n)):
	if n[i] == "Q":
		sheathQ = list(n)
		sheathA = list(n)
		for j in range(i+1, len(n)):
			if sheathA[j] == "A":
				sheathQ = list(n)
				for k in range(j+1, len(n)):
					if sheathQ[k] == "Q":
						ans += 1
						sheathQ[k] = None
				sheathA[j] = None

print(ans)