import std.stdio, std.string, std.algorithm, std.range, std.conv, std.typecons, std.math;
void main(){
    auto S = readln.chomp;
    ulong min = 0, max = 0;
    foreach (i,c; S) {
        if (c == 'A') {
            min = i;
            break;
        }
    }
    foreach_reverse (i,c; S) {
        if (c == 'Z') {
            max = i;
            break;
        }
    }
    writeln(max - min + 1);
}