
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1;

    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1;

    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1;

    System.out.println(ans);
  } main {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1;

    System.out.println(ans);
  } @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String str = sc.next(); str sc.next() sc.next sc int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1; ans str.lastIndexOf('Z') - str.indexOf('A') + 1 str.lastIndexOf('Z') - str.indexOf('A') str.lastIndexOf('Z') str.lastIndexOf str 'Z' str.indexOf('A') str.indexOf str 'A' 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1;

    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1;

    System.out.println(ans);
  }
} Main

import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int ans = str.lastIndexOf('Z') - str.indexOf('A') + 1;

    System.out.println(ans);
  }
}
