import std.stdio, std.string, std.algorithm, std.range;

void main() {
    auto S = readln.chomp;
    auto s = 0, e = S.length-1;
    while (S[s] != 'A') {
        s++;
    }
    while (S[e] != 'Z') {
        e--;
    }
    writeln(e - s + 1);
}