program main
implicit None
	integer::n,k,p,a,i,j,b
	integer,allocatable::d(:)
	character(len = 5)::c
	
	read *,n,k
	allocate(d(k))
	
	read *,d
	
	do
		p = 0
		write(c,"(i5)")n
		c =adjustl(c)
		a =len_trim(c)
		do i = 1,a
			do j = 1,k
				read(c(i:i),*)b
				if(b == d(j)) p = 1
			enddo
		enddo
		if(p == 1)then
			n = n + 1
			else
			exit
		endif
	enddo
	
	print *,n
	
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"

@_QFEd.0 = internal unnamed_addr global ptr null
@_QFEd.8 = internal unnamed_addr global i64 0
@_QQcl.e22f584f90c0a6c7ce4950ce8105b05f = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_8013/source.f\00"
@_QQcl.28693529 = linkonce constant [4 x i8] c"(i5)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8
  %2 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %3 = alloca { ptr, i64, i32, i8, i8, i8, i8 }, align 8
  %4 = alloca i32, align 4
  %5 = alloca [5 x i8], align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.e22f584f90c0a6c7ce4950ce8105b05f, i32 7)
  %9 = call i1 @_FortranAioInputInteger(ptr %8, ptr nonnull %7, i32 4)
  %10 = call i1 @_FortranAioInputInteger(ptr %8, ptr nonnull %6, i32 4)
  %11 = call i32 @_FortranAioEndIoStatement(ptr %8)
  %12 = load i32, ptr %6, align 4, !tbaa !3
  %13 = call i32 @llvm.smax.i32(i32 %12, i32 0)
  %14 = zext i32 %13 to i64
  %15 = shl nuw nsw i64 %14, 2
  %16 = call ptr @malloc(i64 %15)
  store ptr %16, ptr @_QFEd.0, align 8, !tbaa !7
  store i64 %14, ptr @_QFEd.8, align 8, !tbaa !7
  %17 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.e22f584f90c0a6c7ce4950ce8105b05f, i32 10)
  %.unpack = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %.unpack198.unpack.unpack200 = load i64, ptr @_QFEd.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %2, align 8, !tbaa !7
  %.fca.1.gep79 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep79, align 8, !tbaa !7
  %.fca.2.gep81 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep81, align 8, !tbaa !7
  %.fca.3.gep83 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep83, align 4, !tbaa !7
  %.fca.4.gep85 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep85, align 1, !tbaa !7
  %.fca.5.gep87 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep87, align 2, !tbaa !7
  %.fca.6.gep89 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep89, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack198.unpack.unpack200, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %2, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %18 = call i1 @_FortranAioInputDescriptor(ptr %17, ptr nonnull %2)
  %19 = call i32 @_FortranAioEndIoStatement(ptr %17)
  %.fca.1.gep96 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 1
  %.fca.2.gep98 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 2
  %.fca.3.gep100 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 3
  %.fca.4.gep102 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 4
  %.fca.5.gep104 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 5
  %.fca.6.gep106 = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %1, i64 0, i32 6
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 1
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 2
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 3
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 4
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 5
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8 }, ptr %3, i64 0, i32 6
  %20 = getelementptr inbounds [5 x [1 x i8]], ptr %5, i64 0, i64 4
  %21 = getelementptr inbounds [5 x [1 x i8]], ptr %5, i64 0, i64 3
  %22 = getelementptr inbounds [5 x [1 x i8]], ptr %5, i64 0, i64 2
  %23 = getelementptr inbounds [5 x [1 x i8]], ptr %5, i64 0, i64 1
  br label %24

24:                                               ; preds = %63, %0
  %25 = call ptr @_FortranAioBeginInternalFormattedOutput(ptr nonnull %5, i64 5, ptr nonnull @_QQcl.28693529, i64 4, ptr null, ptr null, i64 0, ptr nonnull @_QQcl.e22f584f90c0a6c7ce4950ce8105b05f, i32 14)
  %26 = load i32, ptr %7, align 4, !tbaa !3
  %27 = call i1 @_FortranAioOutputInteger32(ptr %25, i32 %26)
  %28 = call i32 @_FortranAioEndIoStatement(ptr %25)
  store ptr %5, ptr %1, align 8, !tbaa !7
  store i64 5, ptr %.fca.1.gep96, align 8, !tbaa !7
  store i32 20180515, ptr %.fca.2.gep98, align 8, !tbaa !7
  store i8 0, ptr %.fca.3.gep100, align 4, !tbaa !7
  store i8 40, ptr %.fca.4.gep102, align 1, !tbaa !7
  store i8 0, ptr %.fca.5.gep104, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep106, align 1, !tbaa !7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  store i8 0, ptr %.fca.3.gep, align 4, !tbaa !7
  store i8 40, ptr %.fca.4.gep, align 1, !tbaa !7
  store i8 2, ptr %.fca.5.gep, align 2, !tbaa !7
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %29 = call {} @_FortranAAdjustl(ptr nonnull %3, ptr nonnull %1, ptr nonnull @_QQcl.e22f584f90c0a6c7ce4950ce8105b05f, i32 15)
  %.fca.0.load = load ptr, ptr %3, align 8, !tbaa !7
  %.fca.1.load = load i64, ptr %.fca.1.gep, align 8, !tbaa !7
  %30 = call i64 @llvm.smin.i64(i64 %.fca.1.load, i64 5)
  call void @llvm.memmove.p0.p0.i64(ptr nonnull align 1 %5, ptr align 1 %.fca.0.load, i64 %30, i1 false)
  %31 = sub i64 5, %30
  %32 = icmp sgt i64 %31, 0
  br i1 %32, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %24
  %uglygep = getelementptr i8, ptr %5, i64 %30
  call void @llvm.memset.p0.i64(ptr align 1 %uglygep, i8 32, i64 %31, i1 false), !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.preheader, %24
  call void @free(ptr %.fca.0.load)
  %33 = load i8, ptr %20, align 1, !tbaa !3
  %34 = icmp eq i8 %33, 32
  br i1 %34, label %35, label %47

35:                                               ; preds = %._crit_edge
  %36 = load i8, ptr %21, align 1, !tbaa !3
  %37 = icmp eq i8 %36, 32
  br i1 %37, label %38, label %47

38:                                               ; preds = %35
  %39 = load i8, ptr %22, align 1, !tbaa !3
  %40 = icmp eq i8 %39, 32
  br i1 %40, label %41, label %47

41:                                               ; preds = %38
  %42 = load i8, ptr %23, align 1, !tbaa !3
  %43 = icmp eq i8 %42, 32
  br i1 %43, label %44, label %47

44:                                               ; preds = %41
  %45 = load i8, ptr %5, align 1, !tbaa !3
  %46 = icmp eq i8 %45, 32
  br label %47

47:                                               ; preds = %44, %41, %38, %35, %._crit_edge
  %.lcssa234 = phi i64 [ 5, %._crit_edge ], [ 4, %35 ], [ 3, %38 ], [ 2, %41 ], [ 1, %44 ]
  %.lcssa = phi i1 [ %34, %._crit_edge ], [ %37, %35 ], [ %40, %38 ], [ %43, %41 ], [ %46, %44 ]
  br i1 %.lcssa, label %select.unfold._crit_edge.thread, label %.lr.ph223

.lr.ph223:                                        ; preds = %47, %select.unfold
  %indvars.iv227 = phi i64 [ %indvars.iv.next228, %select.unfold ], [ 1, %47 ]
  %.0221 = phi i32 [ %.1.lcssa, %select.unfold ], [ 0, %47 ]
  %48 = load i32, ptr %6, align 4, !tbaa !3
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %.lr.ph219, label %select.unfold

.lr.ph219:                                        ; preds = %.lr.ph223
  %50 = zext i32 %48 to i64
  %51 = add nsw i64 %indvars.iv227, -1
  %52 = getelementptr [5 x [1 x i8]], ptr %5, i64 0, i64 %51
  br label %53

53:                                               ; preds = %.lr.ph219, %53
  %indvars.iv = phi i64 [ 1, %.lr.ph219 ], [ %indvars.iv.next, %53 ]
  %.1217 = phi i32 [ %.0221, %.lr.ph219 ], [ %spec.select, %53 ]
  %54 = call ptr @_FortranAioBeginInternalListInput(ptr %52, i64 1, ptr null, i64 0, ptr nonnull @_QQcl.e22f584f90c0a6c7ce4950ce8105b05f, i32 19)
  %55 = call i1 @_FortranAioInputInteger(ptr %54, ptr nonnull %4, i32 4)
  %56 = call i32 @_FortranAioEndIoStatement(ptr %54)
  %57 = load i32, ptr %4, align 4, !tbaa !3
  %.unpack203 = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %58 = add nsw i64 %indvars.iv, -1
  %59 = getelementptr i32, ptr %.unpack203, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !3
  %61 = icmp eq i32 %57, %60
  %spec.select = select i1 %61, i32 1, i32 %.1217
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %50
  br i1 %exitcond.not, label %select.unfold, label %53

select.unfold:                                    ; preds = %53, %.lr.ph223
  %.1.lcssa = phi i32 [ %.0221, %.lr.ph223 ], [ %spec.select, %53 ]
  %indvars.iv.next228 = add nuw nsw i64 %indvars.iv227, 1
  %exitcond230.not235 = icmp ne i64 %.lcssa234, %indvars.iv227
  %exitcond230.not.not = select i1 %.lcssa, i1 true, i1 %exitcond230.not235
  br i1 %exitcond230.not.not, label %.lr.ph223, label %select.unfold._crit_edge

select.unfold._crit_edge:                         ; preds = %select.unfold
  %62 = icmp eq i32 %.1.lcssa, 1
  br i1 %62, label %63, label %select.unfold._crit_edge.thread

63:                                               ; preds = %select.unfold._crit_edge
  %64 = load i32, ptr %7, align 4, !tbaa !3
  %65 = add i32 %64, 1
  store i32 %65, ptr %7, align 4, !tbaa !3
  br label %24

select.unfold._crit_edge.thread:                  ; preds = %47, %select.unfold._crit_edge
  %66 = call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.e22f584f90c0a6c7ce4950ce8105b05f, i32 30)
  %67 = load i32, ptr %7, align 4, !tbaa !3
  %68 = call i1 @_FortranAioOutputInteger32(ptr %66, i32 %67)
  %69 = call i32 @_FortranAioEndIoStatement(ptr %66)
  ret void
}

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

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

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

declare i1 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare {} @_FortranAAdjustl(ptr, ptr, ptr, i32) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
