arr = []
arr = input()
arr = arr.split()
print(*arr, sep = ", ")
for i in arr:
g = int(i)
sum = 10
cycle = 0
while sum > 9:
if(g < 10):
break
sum = 0
while g > 0:
u = g%10
sum += u
g -= u
g /= 10
g = sum
cycle +=1
print("AP(", end = "")
print(i, end = "")
print(") = ", end = "")
if(i == arr[-1]):
print(cycle, end = "")
else:
print(cycle)
YXJyID0gW10KYXJyID0gaW5wdXQoKQphcnIgPSBhcnIuc3BsaXQoKQpwcmludCgqYXJyLCBzZXAgPSAiLCAiKQoKZm9yIGkgaW4gYXJyOgoJZyA9IGludChpKQoJc3VtID0gMTAKCWN5Y2xlID0gMAoJd2hpbGUgc3VtID4gOToKCQlpZihnIDwgMTApOgoJCQlicmVhawoJCXN1bSA9IDAKCQl3aGlsZSBnID4gMDoKCQkJdSA9IGclMTAKCQkJc3VtICs9IHUKCQkJZyAtPSB1CgkJCWcgLz0gMTAKCQlnID0gc3VtCgkJY3ljbGUgKz0xCglwcmludCgiQVAoIiwgZW5kID0gIiIpCglwcmludChpLCBlbmQgPSAiIikKCXByaW50KCIpID0gIiwgZW5kID0gIiIpCglpZihpID09IGFyclstMV0pOgoJCXByaW50KGN5Y2xlLCBlbmQgPSAiIikKCWVsc2U6IAoJCXByaW50KGN5Y2xlKQ==