unittest
{
	assert( [ "QWERTYASDFZXCV" ].parse.expand.solve == 5 );
	assert( [ "ZABCZ" ].parse.expand.solve == 4 );
	assert( [ "HASFJGHOGAKZZFEGA" ].parse.expand.solve == 12 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	return s.find( 'A' ).retro.find( 'Z' ).walkLength;
}
