#import <stdio.h>
#import <string.h>
int main() {
    char S[200005];
    scanf("%s", S);
    long s = strlen(S);
    long a;
    for (a=0;a<s;a++){
        if (S[a]=='A') {
            break;
        }
    }
    long b;
    for (b=s-1;b>=0;b--){
        if (S[b]=='Z') {
            break;
        }
    }
    printf("%ld", b-a+1);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_838/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_838/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@.str = private unnamed_addr constant [3 x i8] c"%s\00", align 1
@.str.1 = private unnamed_addr constant [4 x i8] c"%ld\00", align 1

; Function Attrs: nofree nounwind uwtable
define dso_local i32 @main() local_unnamed_addr #0 {
entry:
  %S = alloca [200005 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 200005, ptr nonnull %S) #5
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %S)
  %call2 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %S) #6
  %cmp26 = icmp sgt i64 %call2, 0
  br i1 %cmp26, label %for.body, label %for.end

for.body:                                         ; preds = %entry, %for.inc
  %a.027 = phi i64 [ %inc, %for.inc ], [ 0, %entry ]
  %arrayidx = getelementptr inbounds [200005 x i8], ptr %S, i64 0, i64 %a.027
  %0 = load i8, ptr %arrayidx, align 1, !tbaa !5
  %cmp3 = icmp eq i8 %0, 65
  br i1 %cmp3, label %for.end, label %for.inc

for.inc:                                          ; preds = %for.body
  %inc = add nuw nsw i64 %a.027, 1
  %exitcond.not = icmp eq i64 %inc, %call2
  br i1 %exitcond.not, label %for.end, label %for.body

for.end:                                          ; preds = %for.inc, %for.body, %entry
  %a.0.lcssa = phi i64 [ 0, %entry ], [ %a.027, %for.body ], [ %call2, %for.inc ]
  %smin = call i64 @llvm.smin.i64(i64 %call2, i64 0)
  br label %for.cond5

for.cond5:                                        ; preds = %for.body8, %for.end
  %b.0.in = phi i64 [ %call2, %for.end ], [ %b.0, %for.body8 ]
  %cmp6 = icmp sgt i64 %b.0.in, 0
  br i1 %cmp6, label %for.body8, label %for.end16

for.body8:                                        ; preds = %for.cond5
  %b.0 = add nsw i64 %b.0.in, -1
  %arrayidx9 = getelementptr inbounds [200005 x i8], ptr %S, i64 0, i64 %b.0
  %1 = load i8, ptr %arrayidx9, align 1, !tbaa !5
  %cmp11 = icmp eq i8 %1, 90
  br i1 %cmp11, label %for.end16, label %for.cond5

for.end16:                                        ; preds = %for.body8, %for.cond5
  %b.0.in.lcssa = phi i64 [ %b.0.in, %for.body8 ], [ %smin, %for.cond5 ]
  %2 = sub i64 %b.0.in.lcssa, %a.0.lcssa
  %call18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %2)
  call void @llvm.lifetime.end.p0(i64 200005, ptr nonnull %S) #5
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #4

attributes #0 = { nofree nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
