program ABC042C
    implicit none
    integer(8)::N,K,i,j,h,ans,hmod
    integer(8)::flg=0
    integer(8),allocatable,dimension(:)::D
    read(5,*)N,K
    allocate(D(K))
    read(5,*)(D(i),i=1,K)
    do i=N,10*N
        flg=0
        h=i
        do
            hmod=mod(h,10)
            do j=1,K
                if(D(j)==hmod)then
                    flg=1
                    exit
                end if
            end do
            h=h/10
            if(h==0)exit
        end do
        if(flg==0)then
            ans=i
            exit
        end if
    end do
    print'(i0)',ans
end program ABC042C
; 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
@_QQcl.69005ec2a5e83f9e79efd408154476aa = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_8015/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_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

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.69005ec2a5e83f9e79efd408154476aa, i32 6)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 8)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i64, ptr %1, align 8, !tbaa !3
  %8 = call i64 @llvm.smax.i64(i64 %7, i64 0)
  %9 = shl i64 %8, 3
  %10 = call ptr @malloc(i64 %9)
  store ptr %10, ptr @_QFEd.0, align 8, !tbaa !7
  %11 = call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.69005ec2a5e83f9e79efd408154476aa, i32 8)
  %12 = load i64, ptr %1, align 8, !tbaa !3
  %13 = icmp sgt i64 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %14 = phi i64 [ %18, %.lr.ph ], [ 1, %0 ]
  %.unpack89 = load ptr, ptr @_QFEd.0, align 8, !tbaa !7
  %15 = add i64 %14, -1
  %16 = getelementptr i64, ptr %.unpack89, i64 %15
  %17 = call i1 @_FortranAioInputInteger(ptr %11, ptr %16, i32 8)
  %18 = add nuw i64 %14, 1
  %exitcond.not = icmp eq i64 %14, %12
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  %19 = call i32 @_FortranAioEndIoStatement(ptr %11)
  %20 = load i64, ptr %2, align 8, !tbaa !3
  %21 = mul i64 %20, 9
  %22 = icmp ult i64 %21, 9223372036854775807
  br i1 %22, label %.lr.ph110, label %.sink.split

.lr.ph110:                                        ; preds = %._crit_edge
  %23 = load i64, ptr %1, align 8, !tbaa !3
  %24 = icmp sgt i64 %23, 0
  %.unpack = load ptr, ptr @_QFEd.0, align 8
  br i1 %24, label %.split.us.us.preheader, label %.loopexit

.split.us.us.preheader:                           ; preds = %.lr.ph110
  %25 = add nuw nsw i64 %21, 1
  br label %.split.us.us

.split.us.us:                                     ; preds = %.split.us.us.preheader, %.split106.us.us.thread
  %.062108.us = phi i64 [ %27, %.split106.us.us.thread ], [ %20, %.split.us.us.preheader ]
  %.066107.us = phi i64 [ %26, %.split106.us.us.thread ], [ %25, %.split.us.us.preheader ]
  br label %.lr.ph104.us.us.outer

.lr.ph104.us.us.outer:                            ; preds = %..loopexit_crit_edge.us.us.thread, %.split.us.us
  %.ph = phi i1 [ true, %..loopexit_crit_edge.us.us.thread ], [ false, %.split.us.us ]
  %.064.us.us.ph = phi i64 [ %30, %..loopexit_crit_edge.us.us.thread ], [ %.062108.us, %.split.us.us ]
  br label %.lr.ph104.us.us

.split106.us.us.thread:                           ; preds = %..loopexit_crit_edge.us.us.thread, %.split106.us.us
  %26 = add i64 %.066107.us, -1
  %27 = add i64 %.062108.us, 1
  %28 = icmp sgt i64 %26, 0
  br i1 %28, label %.split.us.us, label %.sink.split

.lr.ph104.us.us:                                  ; preds = %.lr.ph104.us.us.outer, %..loopexit_crit_edge.us.us
  %.064.us.us = phi i64 [ %38, %..loopexit_crit_edge.us.us ], [ %.064.us.us.ph, %.lr.ph104.us.us.outer ]
  %29 = srem i64 %.064.us.us, 10
  %30 = sdiv i64 %.064.us.us, 10
  br label %31

31:                                               ; preds = %36, %.lr.ph104.us.us
  %.0102.us.us = phi i64 [ 1, %.lr.ph104.us.us ], [ %37, %36 ]
  %32 = add i64 %.0102.us.us, -1
  %33 = getelementptr i64, ptr %.unpack, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !3
  %35 = icmp eq i64 %34, %29
  br i1 %35, label %..loopexit_crit_edge.us.us.thread, label %36

36:                                               ; preds = %31
  %37 = add nuw i64 %.0102.us.us, 1
  %exitcond124.not = icmp eq i64 %.0102.us.us, %23
  br i1 %exitcond124.not, label %..loopexit_crit_edge.us.us, label %31

..loopexit_crit_edge.us.us:                       ; preds = %36
  %38 = sdiv i64 %.064.us.us, 10
  %.064.off.us.us = add i64 %.064.us.us, 9
  %39 = icmp ult i64 %.064.off.us.us, 19
  br i1 %39, label %.split106.us.us, label %.lr.ph104.us.us

..loopexit_crit_edge.us.us.thread:                ; preds = %31
  %.064.off.us.us125 = add i64 %.064.us.us, 9
  %40 = icmp ult i64 %.064.off.us.us125, 19
  br i1 %40, label %.split106.us.us.thread, label %.lr.ph104.us.us.outer

.split106.us.us:                                  ; preds = %..loopexit_crit_edge.us.us
  br i1 %.ph, label %.split106.us.us.thread, label %.sink.split

.loopexit:                                        ; preds = %.lr.ph110, %.loopexit
  %.064 = phi i64 [ %41, %.loopexit ], [ %20, %.lr.ph110 ]
  %41 = sdiv i64 %.064, 10
  %.064.off = add i64 %.064, 9
  %42 = icmp ult i64 %.064.off, 19
  br i1 %42, label %.sink.split, label %.loopexit

.sink.split:                                      ; preds = %.loopexit, %.split106.us.us, %.split106.us.us.thread, %._crit_edge
  %.062.lcssa = phi i64 [ %20, %._crit_edge ], [ %.062108.us, %.split106.us.us ], [ %27, %.split106.us.us.thread ], [ %20, %.loopexit ]
  %43 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.69005ec2a5e83f9e79efd408154476aa, i32 28)
  %44 = call i1 @_FortranAioOutputInteger64(ptr %43, i64 %.062.lcssa)
  %45 = call i32 @_FortranAioEndIoStatement(ptr %43)
  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 ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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

!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}
