program ABC106C
    implicit none
    integer(8)::K,i
    character(1)::ans
    character(100)::S
    read*,S,K

    do i=1,len_trim(S)
        if(S(i:i)=="1")then
            K=K-1
        else
            ans=S(i:i)
            exit
        end if
    end do
    if(K<1)then
        ans="1"
    end if

    print'(A)',ans
end program ABC106C
; 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 [100 x i8] undef
@_QQcl.a67b3d75da017345b1dfe64d032f8454 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_5652/source.f\00"
@_QQcl.31 = linkonce constant [1 x i8] c"1"
@_QQcl.284129 = linkonce constant [3 x i8] c"(A)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca [1 x i8], align 1
  %2 = alloca i64, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.a67b3d75da017345b1dfe64d032f8454, i32 6)
  %4 = tail call i1 @_FortranAioInputAscii(ptr %3, ptr nonnull @_QFEs, i64 100)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  br label %7

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

15:                                               ; preds = %7
  %16 = shl i64 %8, 32
  %sext = add i64 %16, 4294967296
  %17 = ashr exact i64 %sext, 32
  %spec.select = select i1 %11, i64 0, i64 %17
  %18 = icmp sgt i64 %spec.select, 0
  br i1 %18, label %.lr.ph, label %.loopexitthread-pre-split

.lr.ph:                                           ; preds = %15, %select.unfold
  %.012 = phi i64 [ %25, %select.unfold ], [ 1, %15 ]
  %19 = add nsw i64 %.012, -1
  %20 = getelementptr [100 x [1 x i8]], ptr @_QFEs, i64 0, i64 %19
  %21 = call i32 @_FortranACharacterCompareScalar1(ptr %20, ptr nonnull @_QQcl.31, i64 1, i64 1)
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %select.unfold, label %26

select.unfold:                                    ; preds = %.lr.ph
  %23 = load i64, ptr %2, align 8, !tbaa !3
  %24 = add i64 %23, -1
  store i64 %24, ptr %2, align 8, !tbaa !3
  %25 = add nuw nsw i64 %.012, 1
  %exitcond.not = icmp eq i64 %.012, %spec.select
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph

26:                                               ; preds = %.lr.ph
  %27 = load i8, ptr %20, align 1
  store i8 %27, ptr %1, align 1
  br label %.loopexitthread-pre-split

.loopexitthread-pre-split:                        ; preds = %26, %15
  %.pr = load i64, ptr %2, align 8, !tbaa !3
  br label %.loopexit

.loopexit:                                        ; preds = %select.unfold, %.loopexitthread-pre-split
  %28 = phi i64 [ %.pr, %.loopexitthread-pre-split ], [ %24, %select.unfold ]
  %29 = icmp slt i64 %28, 1
  br i1 %29, label %30, label %31

30:                                               ; preds = %.loopexit
  %.unpack = load i8, ptr @_QQcl.31, align 1, !tbaa !3
  store i8 %.unpack, ptr %1, align 1, !tbaa !3
  br label %31

31:                                               ; preds = %30, %.loopexit
  %32 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.a67b3d75da017345b1dfe64d032f8454, i32 20)
  %33 = call i1 @_FortranAioOutputAscii(ptr %32, ptr nonnull %1, i64 1)
  %34 = call i32 @_FortranAioEndIoStatement(ptr %32)
  ret void
}

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

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

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) 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"}
