import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    in.close();
    
    int a_location = 0;
    int z_location = 0;
    for(int i=0; i<s.length(); i++) {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    }
    
    for(int i=0; i<s.length(); i++) {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    }

    System.out.println(z_location - a_location + 1);
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    in.close();
    
    int a_location = 0;
    int z_location = 0;
    for(int i=0; i<s.length(); i++) {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    }
    
    for(int i=0; i<s.length(); i++) {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    }

    System.out.println(z_location - a_location + 1);
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    in.close();
    
    int a_location = 0;
    int z_location = 0;
    for(int i=0; i<s.length(); i++) {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    }
    
    for(int i=0; i<s.length(); i++) {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    }

    System.out.println(z_location - a_location + 1);
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    in.close();
    
    int a_location = 0;
    int z_location = 0;
    for(int i=0; i<s.length(); i++) {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    }
    
    for(int i=0; i<s.length(); i++) {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    }

    System.out.println(z_location - a_location + 1);
  } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String s = in.readLine(); s in.readLine() in.readLine in in.close() in.close in int a_location = 0; a_location 0 int z_location = 0; z_location 0 for(int i=0; i<s.length(); i++) {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    } {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    } if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      } s.charAt(i)=='A' s.charAt(i) s.charAt s i 'A' {
        a_location = i+1;
        break;
      } a_location = i+1 a_location i+1 i 1 break; for(int i=0; i<s.length(); i++) {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    } int i=0; int i=0; i 0 i<s.length() i s.length() s.length s i++ i++ i {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    } {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    } if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      } a_location != 0 && s.charAt(i)=='Z' a_location != 0 a_location 0 s.charAt(i)=='Z' s.charAt(i) s.charAt s i 'Z' {
        z_location = i+1;
      } z_location = i+1 z_location i+1 i 1 System.out.println(z_location - a_location + 1) System.out.println System.out System System.out z_location - a_location + 1 z_location - a_location z_location a_location 1 String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    in.close();
    
    int a_location = 0;
    int z_location = 0;
    for(int i=0; i<s.length(); i++) {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    }
    
    for(int i=0; i<s.length(); i++) {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    }

    System.out.println(z_location - a_location + 1);
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    in.close();
    
    int a_location = 0;
    int z_location = 0;
    for(int i=0; i<s.length(); i++) {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    }
    
    for(int i=0; i<s.length(); i++) {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    }

    System.out.println(z_location - a_location + 1);
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    in.close();
    
    int a_location = 0;
    int z_location = 0;
    for(int i=0; i<s.length(); i++) {
      if(s.charAt(i)=='A') {
        a_location = i+1;
        break;
      }
    }
    
    for(int i=0; i<s.length(); i++) {
      if(a_location != 0 && s.charAt(i)=='Z') {
        z_location = i+1;
      }
    }

    System.out.println(z_location - a_location + 1);
  }
}