def resolve():

    s=eval(input())

    t=0

    while s[t]!='A':

        t+=1

    b=-1

    while s[b]!='Z':

        b-=1

    print((len(s[t:b])+1))

resolve()
s=eval(input())

t,b=0,len(s)-1

while s[t]!='A':

	t+=1

while s[b]!='Z':

	b-=1

print((b-t+1))
def resolve():
    s = eval(input())
    t = 0
    while s[t] != "A":
        t += 1
    b = -1
    while s[b] != "Z":
        b -= 1
    print((len(s[t:b]) + 1))


resolve()

s = eval(input())
t, b = 0, len(s) - 1
while s[t] != "A":
    t += 1
while s[b] != "Z":
    b -= 1
print((b - t + 1))

-def resolve(): -    s = eval(input()) -    t = 0 -    while s[t] != "A": -        t += 1 -    b = -1 -    while s[b] != "Z": -        b -= 1 -    print((len(s[t:b]) + 1)) - - -resolve() +s = eval(input()) +t, b = 0, len(s) - 1 +while s[t] != "A": +    t += 1 +while s[b] != "Z": +    b -= 1 +print((b - t + 1))