import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    auto s = readln.chomp;
    int from = s.size, to = -1;
    foreach (int i, c; s) {
        if (c == 'A') {
            from = min(i, from);
        } else if (c == 'Z') {
            to = max(i, to);
        }
    }
    writeln(to - from + 1);
}
