program ABC149C
    implicit none
    integer(8)::X,i,j,div_max,flg
    read(5,*)X

    if(X==2)then
        print'(i0)',2
    else
        do i=X,100003
            div_max=int(sqrt(real(i)))+1
            flg=0
            do j=2,div_max
                if(mod(i,j)==0)then
                    flg=1
                    exit
                end if
            end do

            if(flg==0)then
                print'(i0)',i
                exit
            end if
        end do
    end if

end program ABC149C
; 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"

@_QQcl.2410ddd13632ffdf23418117ade66af2 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_2739/source.f\00"
@_QQcl.28693029 = linkonce constant [4 x i8] c"(i0)"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

define void @_QQmain() local_unnamed_addr {
  %1 = alloca i64, align 8
  %2 = tail call ptr @_FortranAioBeginExternalListInput(i32 5, ptr nonnull @_QQcl.2410ddd13632ffdf23418117ade66af2, i32 4)
  %3 = call i1 @_FortranAioInputInteger(ptr %2, ptr nonnull %1, i32 8)
  %4 = call i32 @_FortranAioEndIoStatement(ptr %2)
  %5 = load i64, ptr %1, align 8, !tbaa !3
  %6 = icmp eq i64 %5, 2
  br i1 %6, label %7, label %10

7:                                                ; preds = %0
  %8 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.2410ddd13632ffdf23418117ade66af2, i32 7)
  %9 = call i1 @_FortranAioOutputInteger32(ptr %8, i32 2)
  br label %.loopexit.sink.split

10:                                               ; preds = %0
  %11 = sub i64 100004, %5
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph25, label %.loopexit

.lr.ph25:                                         ; preds = %10, %25
  %.01224 = phi i64 [ %27, %25 ], [ %5, %10 ]
  %.01523 = phi i64 [ %26, %25 ], [ %11, %10 ]
  %13 = sitofp i64 %.01224 to float
  %14 = call contract float @llvm.sqrt.f32(float %13)
  %15 = fptosi float %14 to i32
  %16 = add i32 %15, 1
  %17 = icmp slt i32 %16, 2
  br i1 %17, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph25
  %18 = zext i32 %16 to i64
  br label %.lr.ph

19:                                               ; preds = %.lr.ph
  %20 = add nuw nsw i64 %.019, 1
  %exitcond = icmp eq i64 %.019, %18
  br i1 %exitcond, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %19
  %.019 = phi i64 [ %20, %19 ], [ 2, %.lr.ph.preheader ]
  %21 = srem i64 %.01224, %.019
  %22 = icmp eq i64 %21, 0
  br i1 %22, label %25, label %19

.critedge:                                        ; preds = %.lr.ph25, %19
  %23 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.2410ddd13632ffdf23418117ade66af2, i32 20)
  %24 = call i1 @_FortranAioOutputInteger64(ptr %23, i64 %.01224)
  br label %.loopexit.sink.split

25:                                               ; preds = %.lr.ph
  %26 = add i64 %.01523, -1
  %27 = add i64 %.01224, 1
  %28 = icmp sgt i64 %26, 0
  br i1 %28, label %.lr.ph25, label %.loopexit

.loopexit.sink.split:                             ; preds = %.critedge, %7
  %.sink = phi ptr [ %8, %7 ], [ %23, %.critedge ]
  %29 = call i32 @_FortranAioEndIoStatement(ptr %.sink)
  br label %.loopexit

.loopexit:                                        ; preds = %25, %.loopexit.sink.split, %10
  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 @_FortranAioOutputInteger32(ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.sqrt.f32(float) #0

attributes #0 = { mustprogress 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"}
