Option Strict On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim s As String = ReadLine()

        Dim best As Integer = 0
        Dim cnt As Integer = 0
        Dim flg As Boolean = False

        For Each v As Char In s
            If v = "A"c Then flg = True
            If flg Then cnt += 1
            If flg AndAlso v = "Z"c Then best = cnt
        Next

        WriteLine(best)
    End Sub

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
