import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto s = sread();
    long n = s.length;
    long max_x = long.min;
    long min_x = long.max;
    foreach (i; 0 .. n)
    {
        if (s[i] == 'A')
        {
            // writeln(i);
            min_x = min(min_x, i);

        }
    }
    foreach (i; 0 .. n)
    {
        if (s[i] == 'Z')
        {
            // writeln(i);
            max_x = max(max_x, i);
        }
    }
    // writeln(min_x);
    // writeln(max_x);
    writeln(max_x - min_x + 1);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
