import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    String s;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	int bg = s.indexOf("A");
	int ed = s.lastIndexOf("Z");

	out(ed - bg + 1);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	s = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util import java.util.Comparator; Comparator java.util import java.util.Map; Map java.util import java.util.HashMap; HashMap java.util public class Main
{
    String s;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	int bg = s.indexOf("A");
	int ed = s.lastIndexOf("Z");

	out(ed - bg + 1);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	s = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
} Main String s; s public static void main(String args[])
    {
	new Main().solve();
    } main {
	new Main().solve();
    } new Main().solve() new Main().solve new Main() String args[] args void solve()
    {
	in();

	int bg = s.indexOf("A");
	int ed = s.lastIndexOf("Z");

	out(ed - bg + 1);
    } solve {
	in();

	int bg = s.indexOf("A");
	int ed = s.lastIndexOf("Z");

	out(ed - bg + 1);
    } in() in int bg = s.indexOf("A"); bg s.indexOf("A") s.indexOf s "A" int ed = s.lastIndexOf("Z"); ed s.lastIndexOf("Z") s.lastIndexOf s "Z" out(ed - bg + 1) out ed - bg + 1 ed - bg ed bg 1 void in()
    {
	Scanner sc = new Scanner(System.in);
	s = sc.next();
    } in {
	Scanner sc = new Scanner(System.in);
	s = sc.next();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) s = sc.next() s sc.next() sc.next sc void out()
    {
	
    } out {
	
    } void out(int n)
    {
	System.out.println(n);
    } out {
	System.out.println(n);
    } System.out.println(n) System.out.println System.out System System.out n int n n void out(char c)
    {
	System.out.print(c);
    } out {
	System.out.print(c);
    } System.out.print(c) System.out.print System.out System System.out c char c c void out(String s)
    {
	System.out.println(s);
    } out {
	System.out.println(s);
    } System.out.println(s) System.out.println System.out System System.out s String s s public class Main
{
    String s;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	int bg = s.indexOf("A");
	int ed = s.lastIndexOf("Z");

	out(ed - bg + 1);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	s = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
} public class Main
{
    String s;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	int bg = s.indexOf("A");
	int ed = s.lastIndexOf("Z");

	out(ed - bg + 1);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	s = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
} Main
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    String s;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	int bg = s.indexOf("A");
	int ed = s.lastIndexOf("Z");

	out(ed - bg + 1);
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	s = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
}
