program main
    implicit none
    integer(8)::A(6)=(/1,0,0,1,1,1/),a_count=0,flg=1,cur=1,i
    character(50)::S,T="KIHBR"
    read*,S
    if(len_trim(S)>9)flg=0
    do i=1,len_trim(S)
        if(S(i:i)=="A")then
            a_count=a_count+1
        else if(S(i:i)==T(cur:cur))then
            if(a_count>A(cur))then
                flg=0
                exit
            else
                a_count=0
                cur=cur+1
            end if
        else
            flg=0
            exit
        end if
    end do
    if(flg==1.and.a_count>A(6))flg=0
    if(flg==1.and.cur<6)flg=0
    if(flg==1)print'(A)',"YES"
    if(flg==0)print'(A)',"NO"
end program main
; 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"

@_QFEa = internal unnamed_addr constant [6 x i64] [i64 1, i64 0, i64 0, i64 1, i64 1, i64 1]
@_QFEa_count = internal unnamed_addr global i64 0
@_QFEcur = internal unnamed_addr global i64 1
@_QFEflg = internal unnamed_addr global i1 false
@_QFEs = internal global [50 x i8] undef
@_QFEt = internal global [50 x i8] c"KIHBR                                             "
@_QQcl.4b15ea1c92e8cb71e1bbc9e83f379b73 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_6659/source.f\00"
@_QQcl.41 = linkonce constant [1 x i8] c"A"
@_QQcl.284129 = linkonce constant [3 x i8] c"(A)"
@_QQcl.594553 = linkonce constant [3 x i8] c"YES"
@_QQcl.4E4F = linkonce constant [2 x i8] c"NO"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

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

4:                                                ; preds = %0, %4
  %5 = phi i64 [ 49, %0 ], [ %9, %4 ]
  %6 = getelementptr [50 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 = trunc i64 %5 to i32
  %14 = add i32 %13, 1
  %15 = icmp slt i32 %14, 10
  %.not11 = select i1 %8, i1 true, i1 %15
  br i1 %.not11, label %.preheader, label %16

16:                                               ; preds = %12
  store i1 true, ptr @_QFEflg, align 1
  br label %.preheader

.preheader:                                       ; preds = %16, %12
  br label %17

17:                                               ; preds = %.preheader, %17
  %18 = phi i64 [ %22, %17 ], [ 49, %.preheader ]
  %19 = getelementptr [50 x [1 x i8]], ptr @_QFEs, i64 0, i64 %18
  %20 = load i8, ptr %19, align 1, !tbaa !3
  %21 = icmp eq i8 %20, 32
  %22 = add nsw i64 %18, -1
  %23 = icmp ne i64 %18, 0
  %24 = and i1 %21, %23
  br i1 %24, label %17, label %25

25:                                               ; preds = %17
  %26 = shl i64 %18, 32
  %sext = add i64 %26, 4294967296
  %27 = ashr exact i64 %sext, 32
  %spec.select = select i1 %21, i64 0, i64 %27
  %28 = icmp sgt i64 %spec.select, 0
  br i1 %28, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %25, %select.unfold
  %.021 = phi i64 [ %51, %select.unfold ], [ 1, %25 ]
  %29 = add nsw i64 %.021, -1
  %30 = getelementptr [50 x [1 x i8]], ptr @_QFEs, i64 0, i64 %29
  %31 = tail call i32 @_FortranACharacterCompareScalar1(ptr %30, ptr nonnull @_QQcl.41, i64 1, i64 1)
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %.lr.ph
  %34 = load i64, ptr @_QFEa_count, align 8, !tbaa !3
  br label %select.unfold

35:                                               ; preds = %.lr.ph
  %36 = load i64, ptr @_QFEcur, align 8, !tbaa !3
  %37 = add i64 %36, -1
  %38 = getelementptr [50 x [1 x i8]], ptr @_QFEt, i64 0, i64 %37
  %39 = tail call i32 @_FortranACharacterCompareScalar1(ptr %30, ptr %38, i64 1, i64 1)
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %48

41:                                               ; preds = %35
  %42 = load i64, ptr @_QFEa_count, align 8, !tbaa !3
  %43 = load i64, ptr @_QFEcur, align 8, !tbaa !3
  %44 = add i64 %43, -1
  %45 = getelementptr [6 x i64], ptr @_QFEa, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !3
  %47 = icmp sgt i64 %42, %46
  br i1 %47, label %48, label %49

48:                                               ; preds = %41, %35
  store i1 true, ptr @_QFEflg, align 1
  br label %.loopexit

49:                                               ; preds = %41
  store i64 0, ptr @_QFEa_count, align 8, !tbaa !3
  br label %select.unfold

select.unfold:                                    ; preds = %33, %49
  %.sink37 = phi i64 [ %34, %33 ], [ %43, %49 ]
  %_QFEa_count.sink = phi ptr [ @_QFEa_count, %33 ], [ @_QFEcur, %49 ]
  %50 = add i64 %.sink37, 1
  store i64 %50, ptr %_QFEa_count.sink, align 8, !tbaa !3
  %51 = add nuw nsw i64 %.021, 1
  %exitcond.not = icmp eq i64 %.021, %spec.select
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph

.loopexit:                                        ; preds = %select.unfold, %25, %48
  %.b10 = load i1, ptr @_QFEflg, align 1
  %52 = load i64, ptr @_QFEa_count, align 8, !tbaa !3
  %53 = icmp slt i64 %52, 2
  %.not12 = or i1 %.b10, %53
  br i1 %.not12, label %54, label %.thread32.sink.split

54:                                               ; preds = %.loopexit
  %55 = load i64, ptr @_QFEcur, align 8, !tbaa !3
  %56 = icmp sgt i64 %55, 5
  %.not13 = or i1 %.b10, %56
  br i1 %.not13, label %57, label %.thread32.sink.split

57:                                               ; preds = %54
  br i1 %.b10, label %.thread32, label %58

58:                                               ; preds = %57
  %59 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.4b15ea1c92e8cb71e1bbc9e83f379b73, i32 25)
  %60 = tail call i1 @_FortranAioOutputAscii(ptr %59, ptr nonnull @_QQcl.594553, i64 3)
  %61 = tail call i32 @_FortranAioEndIoStatement(ptr %59)
  %.b.pr.pre = load i1, ptr @_QFEflg, align 1
  br i1 %.b.pr.pre, label %.thread32, label %65

.thread32.sink.split:                             ; preds = %54, %.loopexit
  store i1 true, ptr @_QFEflg, align 1
  br label %.thread32

.thread32:                                        ; preds = %.thread32.sink.split, %57, %58
  %62 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.4b15ea1c92e8cb71e1bbc9e83f379b73, i32 26)
  %63 = tail call i1 @_FortranAioOutputAscii(ptr %62, ptr nonnull @_QQcl.4E4F, i64 2)
  %64 = tail call i32 @_FortranAioEndIoStatement(ptr %62)
  br label %65

65:                                               ; preds = %.thread32, %58
  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 @_FortranAioOutputAscii(ptr, 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"}
