program ABC053B
    implicit none
    integer(8)::i,top,tail,s_len
    character(200000)::s
    read(5,*)s
    s_len=len_trim(s)
    do i=1,s_len
        if(s(i:i)=='A')then
            top=i
            exit
        end if
    end do

    do i=0,s_len-1
        if(s(s_len-i:s_len-i)=='Z')then
            tail=s_len-i
            exit
        end if
    end do

    print'(i0)',tail-top+1
end program ABC053B
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
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"

@_QFEs = internal global [200000 x i8] undef
@_QQcl.ae594ffc0dea131978eedb48430dc0de = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_7531/source.f\00"
@_QQcl.41 = linkonce constant [1 x i8] c"A"
@_QQcl.5A = linkonce constant [1 x i8] c"Z"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.ae594ffc0dea131978eedb48430dc0de, i32 5)
  %2 = tail call i1 @_FortranAioInputAscii(ptr %1, ptr nonnull @_QFEs, i64 200000)
  %3 = tail call i32 @_FortranAioEndIoStatement(ptr %1)
  br label %4

4:                                                ; preds = %0, %4
  %5 = phi i64 [ 199999, %0 ], [ %9, %4 ]
  %6 = getelementptr [200000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !3
  %8 = icmp eq i8 %7, 32
  %9 = add nsw i64 %5, -1
  %10 = icmp ne i64 %5, 0
  %11 = and i1 %8, %10
  br i1 %11, label %4, label %12

12:                                               ; preds = %4
  %13 = shl i64 %5, 32
  %sext = add i64 %13, 4294967296
  %14 = ashr exact i64 %sext, 32
  %15 = select i1 %8, i64 0, i64 %14
  %16 = icmp sgt i64 %15, 0
  br i1 %16, label %.lr.ph.preheader, label %._crit_edge29

.lr.ph.preheader:                                 ; preds = %12
  %17 = add nuw nsw i64 %15, 1
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %22
  %.01822 = phi i64 [ %23, %22 ], [ 1, %.lr.ph.preheader ]
  %18 = add nsw i64 %.01822, -1
  %19 = getelementptr [200000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %18
  %20 = tail call i32 @_FortranACharacterCompareScalar1(ptr %19, ptr nonnull @_QQcl.41, i64 1, i64 1)
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %._crit_edge, label %22

22:                                               ; preds = %.lr.ph
  %23 = add nuw nsw i64 %.01822, 1
  %exitcond.not = icmp eq i64 %.01822, %15
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %22, %.lr.ph
  %.018.lcssa = phi i64 [ %17, %22 ], [ %.01822, %.lr.ph ]
  br i1 %16, label %.lr.ph28, label %._crit_edge29

.lr.ph28:                                         ; preds = %._crit_edge, %.lr.ph28
  %.125 = phi i64 [ %29, %.lr.ph28 ], [ 0, %._crit_edge ]
  %24 = sub nuw nsw i64 %15, %.125
  %25 = add nsw i64 %24, -1
  %26 = getelementptr [200000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %25
  %27 = tail call i32 @_FortranACharacterCompareScalar1(ptr %26, ptr nonnull @_QQcl.5A, i64 1, i64 1)
  %28 = icmp eq i32 %27, 0
  %29 = add nuw nsw i64 %.125, 1
  %exitcond34.not = icmp eq i64 %29, %15
  %or.cond = select i1 %28, i1 true, i1 %exitcond34.not
  br i1 %or.cond, label %._crit_edge29, label %.lr.ph28

._crit_edge29:                                    ; preds = %.lr.ph28, %12, %._crit_edge
  %.018.lcssa36 = phi i64 [ %.018.lcssa, %._crit_edge ], [ 1, %12 ], [ %.018.lcssa, %.lr.ph28 ]
  %.016 = phi i64 [ undef, %._crit_edge ], [ undef, %12 ], [ %24, %.lr.ph28 ]
  %30 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.ae594ffc0dea131978eedb48430dc0de, i32 21)
  %31 = sub i64 1, %.018.lcssa36
  %32 = add i64 %31, %.016
  %33 = tail call i1 @_FortranAioOutputInteger64(ptr %30, i64 %32)
  %34 = tail call i32 @_FortranAioEndIoStatement(ptr %30)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputAscii(ptr, ptr, i64) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
