#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  int a, z;
  a = s.find('A');
  z = s.find_last_of('Z');
  int ans = z - a + 1;

  cout << ans <<  endl;
  return 0;
}
