using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AIZUproject07
{
    class Program
    {
        //static string T;
        /*static void Main()
        {
            int count = 0;
            bool flag = false;
            string In = Console.ReadLine();
            string[] s = Console.ReadLine().Split();
            int[] aa = s.Select(int.Parse).ToArray();
            while (true)
            {
                for (int i = 0; i < aa.Length; i++)
                {
                    if (aa[i] % 2 != 0)
                    {
                        flag = true;
                    }
                    
                }
                aa = aa.Select(n => n / 2).ToArray();
                if (flag == true) break;
                count++;
            }
            Console.WriteLine(count);
        }*/
        /*static void Main()
        {
            int sum = 0;
            int count = 0;
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string C = Console.ReadLine();
            string D = Console.ReadLine();
            int AA = int.Parse(A);
            int BB = int.Parse(B);
            int CC = int.Parse(C);
            int DD = int.Parse(D);
            for(int i = 0;i<=AA;i++)
            {
                for (int j=0;j<=BB;j++)
                {
                    for (int k =0;k<=CC;k++)
                    {
                        sum = i * 500 + j * 100 + k * 50;
                        if (sum == DD) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }*/
        /*static void Main()
        {
            int ans1 = 0;
            int ans2 = 0;
            string[] s = Console.ReadLine().Split();
            int[] intArray = s.Select(int.Parse).ToArray();
            for (int i = 1;i<=intArray[0];i++)
            {
                ans1 = 0;
                if (i >= 10 && i <100)
                {
                    var aaa = i % 10;
                    var bbb = i / 10;
                    ans1 = aaa + bbb;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
                if (i >= 100 && i<1000)
                {
                    var aaa = i % 10;
                    var bbb = i / 10;
                    var ccc = bbb % 10;
                    var ddd = bbb / 10;
                    ans1 = aaa + ccc + ddd;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
                if (i >= 1000 && i <10000)
                {
                    var aaa = i % 10;//4
                    var bbb = i / 10;
                    var ccc = bbb % 10;//3
                    var ddd = bbb / 10;
                    var eee = ddd % 10;//2
                    var fff = ddd / 10;//1
                    ans1 = aaa + ccc + eee + fff;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
                if (i == 10000)
                {
                    ans1 = 1;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
                if (i < 10)
                {
                    ans1 = i;
                    if (intArray[1] <= ans1 && ans1 <= intArray[2])
                    {
                        ans2 += i;
                    }
                }
            }
            Console.WriteLine(ans2);
        }*/
        /*static void Main()
        {
            int sum = 0;
            bool test = false;
            string[] aa = Console.ReadLine().Split();
            int N = int.Parse(aa[0]);
            int Y = int.Parse(aa[1]);
            int Yukichi = Y / 10000;
            int Ichiyo = Y / 5000;
            int Hideyo = Y / 1000;
            int x = 0;
            int y = 0;
            int z = 0;
            for (int i = 0;i<=Yukichi;i++)
            {
                for (int j =0;j<=Ichiyo;j++)
                {
                    for (int k =0;k<=Hideyo;k++)
                    {
                        sum = 10000 * i + 5000 * j + 1000 * k;
                        if (sum == Y && i+j+k < N)
                        {
                            x = i;
                            y = j;
                            z = k;
                            //Console.WriteLine(i + " " + j + " " + k);
                            test = true;
                        }
                    }
                }
            }
            if (test == true)
            {
                Console.WriteLine(x + " " + y + " " + z);
            }
            if (test == false)
            {
                Console.WriteLine("-1 -1 -1");
            }
        }*/
        /*static void Main()
        {
            string[] aa = Console.ReadLine().Split();
            int N = int.Parse(aa[0]);
            int Y = int.Parse(aa[1]);
            int X = 0;
            int Z = 0;
            int b = 0;
            int d = 0;
            X = Y / 10000;
            var a = Y - (X*10000);
            if (a != 0 || Y < 10000)
            {
                b = a / 5000;
                var cc = a - (b * 5000);
                if (cc != 0 || a < 5000)
                {
                    d = cc / 1000;
                    var gg = cc - (d * 1000);
                    if (gg != 0 ||  cc<1000)
                    {
                        Console.WriteLine("-1 -1 -1");
                    }
                    else if (X + b + d <= N)
                    {
                        Console.WriteLine(X + " " + b + " " + d);
                    }
                    else if (X + b + d > N)
                    {
                        Console.WriteLine("-1 -1 -1");
                    }
                }
                else if (X + b <= N)
                {
                    Console.WriteLine(X +" "+ b +" "+"0");
                }
                else if (X + b > N)
                {
                    Console.WriteLine("-1 -1 -1");
                }
            }
            else if (X <= N)
            {
                Console.WriteLine(X +" "+0+" "+0);
            }
            else if (X>N)
            {
                Console.WriteLine("-1 -1 -1");
            }
        }*/
        /*static void Main()
        {
            string s = Console.ReadLine();

            var Ans = s.Replace("eraser", "").Replace("dreamer", "").Replace("dreamer", "").Replace("erase", "").ToString();
            if (Ans == null) Console.WriteLine("YES");
            else Console.WriteLine("NO");*/

        //List<string> str = new List<string>(); || s.Substring(5, 1) == ""
        //string NN = new string(s); || s.Substring(5,1) == ""
        /*while (true) { 
            while (true)
            {
                    if (s.StartsWith("dream") && (s.Substring(5,2) != "er" ))
                    {
                        count++;
                        var f = s.Remove(0, 5);
                        s = f;
                        break;
                    }
                    if (s.StartsWith("dreamer"))
                    {

                        var n = s.Remove(0, 7);
                        s = n;
                        break;
                    }
                    if (s.StartsWith("erase") || (s.Substring(5,1) != "r" ))
                    {
                        count2++;
                        var f1 = s.Remove(0, 5);
                        s = f1;
                        break;
                    }
                    if (s.StartsWith("eraser"))
                    {

                        var f2 = s.Remove(0, 6);
                        s = f2;
                        break;
                    }
                else
                {
                    tt = true;
                    break;
                }
            }
            if (s.Length == 0)
            {
                Console.WriteLine("YES");
                break;
            }
            if (tt)
            {
                Console.WriteLine("NO");
                break;
            }
        }*/
        //Console.WriteLine(count+","+count2);
        //}

        //86C
        /*static void Main()
        {
            /*string aa = Console.ReadLine();
            List<int[]> nn = new List<int[]>();
            for (int i = 0;i<aa.Length;i++)
            {
                string[] str = Console.ReadLine().Split();
                int[] intstr = str.Select(int.Parse).ToArray();
                nn.Add(intstr);
            }
            var a1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var num = a1[0];
            var list = new List<int[]>(num);
            for (int i=0;i<num;i++)
            {

            }
        }*/
        /*static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var array = input.Select(int.Parse).ToArray();
            int num = array[0] * 100 + array[1] * 10 + array[2] * 1;
            if (num % 4 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }*/
        /*static void Main()
        {
            var input = Console.ReadLine();
            var a = Console.ReadLine();
            int N = int.Parse(input);
            int A = int.Parse(a);
            bool flag = false;
            for (int i = 0;i <= A;i++ )
            {
                var Ans = N - i;
                if (Ans % 500 == 0)
                {
                    Console.WriteLine("Yes");
                    flag = true;
                    break;
                }
            }
            if (flag == false)
            {
                Console.WriteLine("No");
            }

        }*/
        /*static void Main()
        {
            var a = Console.ReadLine().Split();
            double[] integer = a.Select(double.Parse).ToArray();
            double ans = (integer[0] + integer[1]) / 2;
            Console.WriteLine(Math.Ceiling(ans));
        }*/
        /*static void Main()
        {
            int count = 0;
            string str = Console.ReadLine();
            //var cross = str.Select(n => n != '×');
            //var circle = str.Select(n => n != 'o');
            //Console.WriteLine(cross);
            //Console.WriteLine(circle);
            /*Console.WriteLine(str.Length);
            while (true)
            {
                Match match1 = Regex.Match(str, "o");
                if (match1 != null)
                {
                    count++;
                }
                str = str.Substring(match1.Index+1, str.Length);
                if (match1.Index == str.Length)
                {
                    break;
                }
            }
            var Ans = 700 + count * 100;
            Console.WriteLine(Ans);*/
        //Console.WriteLine(match.Value);
        /*or (int i =0;i<str.Length;i++)
        {
            if (Regex.Match(str[i], "o"))
            {

            }
        }
        count = str.Length - str.Replace("o", "").Length;
        var Ans = 700 + count * 100;
        Console.WriteLine(Ans);
        }*/
        /*static void Main()
        {
            var str = Console.ReadLine();
            var Ans = str.Replace("2017","2018");
            Console.WriteLine(Ans);
        }*/
        /*static void Main()
        {
            var str = Console.ReadLine();
            //str.Substring(0, 1) +
            Console.WriteLine(str.Substring(0, 1) + (str.Length-2) + str.Substring(str.Length-1));
        }*/
        //82B
        /*static void Main()
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            char[] S = s.ToArray();
            char[] T = t.ToArray();
            Array.Sort(S);
            Array.Sort(T);Array.Reverse(T);
            string ss = new string(S);
            string ts = new string(T);
            if (ss.CompareTo(ts) < 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }*/

        //sに関してソート
        /*for (int i = 0; i < s.Length; i++)
        {

        }*/
        //var hoge = s.OrderByDescending((x) => x.Value);
        /*List<int> array = new List<int>();
        int[] rank = new int[s.Length];
        for (int i = 0; i < s.Length; i++)
        {
            rank[i] = 0;
        }
        for (int i = 0; i < s.Length; i++)
        {
            for (int j = 0; j < s.Length; j++)
            {
                if (s[i] > s[j])
                {
                    rank[i]++;
                }
            }
        }
        for (int i=0;i<s.Length;i++)
        {
            for (int j =0;j<s.Length;j++)
            {
                if (i == rank[j])
                {
                    array.Add(s[i]);
                }
            }
        }
        for (int i = 0; i < s.Length; i++)
        {
            Console.Write(array[i]);
        }

    }*/
        /*static void Main()
        {
            int count;
            int temp = 0;
            var N = int.Parse(Console.ReadLine());
            List<int> aa = new List<int>();
            for (int i = 1; i <= N; i++)
            {
                count = 0;
                temp = i;
                while (true)
                {
                    var Ans = temp / 2;
                    var Ans2 = temp % 2;
                    if (Ans2 == 0)
                    {
                        count++;
                        temp = Ans;
                    }
                    else
                    {
                        break;
                    }
                }
                aa.Add(count);
            }
            //Program program = new Program();
            //program.Max(aa, temp);
            var max = aa.IndexOf(aa.Max());
            Console.WriteLine(max+1);

        }
        public void Max(List<int> array,int num)
        {
            var Ans3 = array.Max();
        }*/
        /*static void Main()
        {
            List<int> array = new List<int>();
            var N = Console.ReadLine();
            int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 0;i<A.Length;i++)
            {
                for (int j = 0; j< A.Length; j++)
                {
                    var ans = A[i] - A[j];
                    if (ans < 0)
                    {
                         ans = Math.Abs(ans);
                    }
                    //Console.Write(ans);
                    array.Add(ans);
                }
                //Console.WriteLine();
            }
            Console.WriteLine(array.Max());
        }*/
        /*static void Main()
        {
            var N = Console.ReadLine();
            int[] temperture = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] height = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int T = temperture[0];
            int A = temperture[1];
            List<double> aa = new List<double>();
            List<double> bb = new List<double>();
            for (int i = 0;i<height.Length;i++)
            {
                var temp = T - height[i] * 0.006;
                aa.Add(temp);
            }
            for (int i =0;i<height.Length;i++)
            {
                var temp = A - aa[i];
                if (temp < 0)
                {
                    temp = Math.Abs(temp);
                }
                bb.Add(temp);
            }
            Console.WriteLine(bb.IndexOf(bb.Min())+1);
        }*/
        /*static void Main()
        {
            string a = Console.ReadLine();
            char[] charArray = a.ToArray();
            List<char> aa = new List<char>();
            for (int i = 0;i<charArray.Length;i++)
            {
                if ((i+1)%2 == 1)
                {
                    aa.Add(charArray[i]);
                }
            }
            var str = string.Join("",aa);
            Console.WriteLine(str);
        }*/
        //053B
        static void Main()
        {
            var str = Console.ReadLine();
            var start = str.IndexOf("A");
            var goal = str.IndexOf("Z",start);
            string temp = new string(str.Substring(goal).ToArray());
            int goalpoint = 0;
            /*List<int> kk = new List<int>();
            while (true)
            {
                if (temp.Contains("Z"))
                {
                    goalpoint = temp.IndexOf("Z") +1;
                    temp = temp.Replace("Z", "");
                    
                }
                if (temp.Contains("Z") == false)
                {
                    break;
                }
                if(temp.Contains("Z"))
                {
                    Console.WriteLine();
                }
            }*/
            for (int i = 0;i<temp.Length;i++)
            {
                if (temp[i] == 'Z')
                {
                    goalpoint = i;
                }
                
            }
            var ans = str.Substring(start, goal-start).Length + 1 + goalpoint;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 15584