#!/usr/bin/env python3

import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

inf = float('inf')

ans = 0 ;count = 0 ;pro = 1



s=eval(input())

i=s.find('A')

s=s[::-1]

j=s.find('Z')

print((len(s)-i-j))



#!/usr/bin/env python3

import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')

inf = float('inf') ;mod = 10**9+7

minans = inf ;ans = 0 ;count = 0 ;pro = 1



s=eval(input())

a=s.find("A")

s=s[::-1]

z=s.find("Z")

print((len(s)-z-a))
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
ans = 0
count = 0
pro = 1
s = eval(input())
i = s.find("A")
s = s[::-1]
j = s.find("Z")
print((len(s) - i - j))

#!/usr/bin/env python3
import sys, math, itertools, collections, bisect

input = lambda: sys.stdin.buffer.readline().rstrip().decode("utf-8")
inf = float("inf")
mod = 10**9 + 7
minans = inf
ans = 0
count = 0
pro = 1
s = eval(input())
a = s.find("A")
s = s[::-1]
z = s.find("Z")
print((len(s) - z - a))

+mod = 10**9 + 7 +minans = inf -i = s.find("A") +a = s.find("A") -j = s.find("Z") -print((len(s) - i - j)) +z = s.find("Z") +print((len(s) - z - a))