program main

  implicit none

  integer :: L, R, i, j, ans, ans_tmp
  integer, allocatable, dimension ( : ) :: a

  read ( unit = *, fmt = * ) L, R

  if ( R-L+1 >= 2019 ) then

     print '(i0)', 0

     stop

  end if
  
  allocate ( a ( 1:R-L+1 ) )

  do i = 1, R-L+1
     
     a ( i ) = mod ( L + i - 1, 2019 )

  end do

  ans = 2019
  
  do i = 1, R-L+1

     do j = 1, R-L+1

        if ( i == j ) then

           cycle

        end if

        ans_tmp = mod ( a ( i ) *  a ( j ), 2019 )

        if ( ans_tmp < ans ) ans = ans_tmp

        if ( ans == 0 ) then
           
           print '(i0)', 0

           stop

        end if
        

     end do

  end do

  print '(i0)', ans
  
  
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 global { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } { ptr null, i64 ptrtoint (ptr getelementptr (i32, ptr null, i32 1) to i64), i32 20180515, i8 1, i8 9, i8 2, i8 0, [1 x [3 x i64]] [[3 x i64] [i64 1, i64 0, i64 ptrtoint (ptr getelementptr (i32, ptr null, i32 1) to i64)]] }
@_QQcl.da84defe699650fbd3108606fd6864d3 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3826/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 i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.da84defe699650fbd3108606fd6864d3, i32 8)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 4)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 4)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i32, ptr %2, align 4, !tbaa !3
  %8 = load i32, ptr %1, align 4, !tbaa !3
  %9 = sub i32 %7, %8
  %10 = add i32 %9, 1
  %11 = icmp sgt i32 %10, 2018
  br i1 %11, label %12, label %17

12:                                               ; preds = %0
  %13 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.da84defe699650fbd3108606fd6864d3, i32 12)
  %14 = call i1 @_FortranAioOutputInteger32(ptr %13, i32 0)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %13)
  %16 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

17:                                               ; preds = %0
  %18 = call i32 @llvm.smax.i32(i32 %10, i32 0)
  %19 = zext i32 %18 to i64
  %20 = shl nuw nsw i64 %19, 2
  %21 = call ptr @malloc(i64 %20)
  store ptr %21, ptr @_QFEa, align 16, !tbaa !7
  store i64 4, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 1), align 8, !tbaa !7
  store i32 20180515, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 2), align 16, !tbaa !7
  store i8 1, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 3), align 4, !tbaa !7
  store i8 9, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 4), align 1, !tbaa !7
  store i8 2, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 5), align 2, !tbaa !7
  store i8 0, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 6), align 1, !tbaa !7
  store i64 1, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 7), align 8, !tbaa !7
  store i64 %19, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 7, i64 0, i64 1), align 16, !tbaa !7
  store i64 4, ptr getelementptr inbounds ({ ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @_QFEa, i64 0, i32 7, i64 0, i64 2), align 8, !tbaa !7
  %22 = icmp ult i32 %9, 2147483647
  br i1 %22, label %.lr.ph, label %._crit_edge113

.lr.ph:                                           ; preds = %17
  %23 = zext i32 %10 to i64
  %24 = add nuw nsw i64 %23, 1
  %25 = icmp ne i32 %10, 0
  %umin.neg = sext i1 %25 to i64
  %26 = add nsw i64 %24, %umin.neg
  %min.iters.check = icmp ult i64 %26, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %26, -8
  %ind.end = or i64 %n.vec, 1
  %ind.end119 = sub nsw i64 %23, %n.vec
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %8, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert121 = insertelement <4 x i32> poison, i32 %8, i64 0
  %broadcast.splat122 = shufflevector <4 x i32> %broadcast.splatinsert121, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %27 = or i64 %index, 1
  %28 = or i64 %index, 2
  %29 = or i64 %index, 3
  %30 = insertelement <4 x i64> poison, i64 %index, i64 0
  %31 = insertelement <4 x i64> %30, i64 %27, i64 1
  %32 = insertelement <4 x i64> %31, i64 %28, i64 2
  %33 = insertelement <4 x i64> %32, i64 %29, i64 3
  %34 = or i64 %index, 4
  %35 = or i64 %index, 5
  %36 = or i64 %index, 6
  %37 = or i64 %index, 7
  %38 = insertelement <4 x i64> poison, i64 %34, i64 0
  %39 = insertelement <4 x i64> %38, i64 %35, i64 1
  %40 = insertelement <4 x i64> %39, i64 %36, i64 2
  %41 = insertelement <4 x i64> %40, i64 %37, i64 3
  %42 = trunc <4 x i64> %33 to <4 x i32>
  %43 = trunc <4 x i64> %41 to <4 x i32>
  %44 = add <4 x i32> %broadcast.splat, %42
  %45 = add <4 x i32> %broadcast.splat122, %43
  %46 = srem <4 x i32> %44, <i32 2019, i32 2019, i32 2019, i32 2019>
  %47 = srem <4 x i32> %45, <i32 2019, i32 2019, i32 2019, i32 2019>
  %48 = getelementptr i32, ptr %21, i64 %index
  store <4 x i32> %46, ptr %48, align 4, !tbaa !3
  %49 = getelementptr i32, ptr %48, i64 4
  store <4 x i32> %47, ptr %49, align 4, !tbaa !3
  %index.next = add nuw i64 %index, 8
  %50 = icmp eq i64 %index.next, %n.vec
  br i1 %50, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %26, %n.vec
  br i1 %cmp.n, label %.preheader103, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %.lr.ph, %middle.block
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  %.ph = phi i64 [ %23, %.lr.ph ], [ %ind.end119, %middle.block ]
  br label %scalar.ph

.preheader103:                                    ; preds = %scalar.ph, %middle.block
  br i1 %22, label %.preheader.us, label %._crit_edge113

.preheader.us:                                    ; preds = %.preheader103, %._crit_edge.us
  %.064112.us = phi i32 [ %68, %._crit_edge.us ], [ 1, %.preheader103 ]
  %.066111.us = phi i32 [ %.3.us, %._crit_edge.us ], [ 2019, %.preheader103 ]
  %.067110.us = phi i32 [ %67, %._crit_edge.us ], [ %10, %.preheader103 ]
  %51 = sext i32 %.064112.us to i64
  %52 = add nsw i64 %51, -1
  %53 = getelementptr i32, ptr %21, i64 %52
  %54 = zext i32 %.064112.us to i64
  br label %55

55:                                               ; preds = %.preheader.us, %64
  %indvars.iv116 = phi i64 [ 1, %.preheader.us ], [ %indvars.iv.next117, %64 ]
  %.065107.us = phi i32 [ %10, %.preheader.us ], [ %65, %64 ]
  %.1106.us = phi i32 [ %.066111.us, %.preheader.us ], [ %.3.us, %64 ]
  %.not.us = icmp eq i64 %indvars.iv116, %54
  br i1 %.not.us, label %64, label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %53, align 4, !tbaa !3
  %58 = add nsw i64 %indvars.iv116, -1
  %59 = getelementptr i32, ptr %21, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !3
  %61 = mul i32 %60, %57
  %62 = srem i32 %61, 2019
  %spec.select.us = call i32 @llvm.smin.i32(i32 %62, i32 %.1106.us)
  %63 = icmp eq i32 %spec.select.us, 0
  br i1 %63, label %.split.us, label %64

64:                                               ; preds = %56, %55
  %.3.us = phi i32 [ %spec.select.us, %56 ], [ %.1106.us, %55 ]
  %65 = add nsw i32 %.065107.us, -1
  %indvars.iv.next117 = add nuw nsw i64 %indvars.iv116, 1
  %66 = icmp sgt i32 %.065107.us, 1
  br i1 %66, label %55, label %._crit_edge.us

._crit_edge.us:                                   ; preds = %64
  %67 = add i32 %.067110.us, -1
  %68 = add nuw i32 %.064112.us, 1
  %69 = icmp sgt i32 %67, 0
  br i1 %69, label %.preheader.us, label %._crit_edge113

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %70 = phi i64 [ %76, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %71 = add nsw i64 %indvars.iv, -1
  %72 = trunc i64 %71 to i32
  %73 = add i32 %8, %72
  %74 = srem i32 %73, 2019
  %75 = getelementptr i32, ptr %21, i64 %71
  store i32 %74, ptr %75, align 4, !tbaa !3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %76 = add nsw i64 %70, -1
  %77 = icmp ugt i64 %70, 1
  br i1 %77, label %scalar.ph, label %.preheader103, !llvm.loop !12

.split.us:                                        ; preds = %56
  %78 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.da84defe699650fbd3108606fd6864d3, i32 44)
  %79 = call i1 @_FortranAioOutputInteger32(ptr %78, i32 0)
  %80 = call i32 @_FortranAioEndIoStatement(ptr %78)
  %81 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

._crit_edge113:                                   ; preds = %._crit_edge.us, %17, %.preheader103
  %.066.lcssa = phi i32 [ 2019, %.preheader103 ], [ 2019, %17 ], [ %.3.us, %._crit_edge.us ]
  %82 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.da84defe699650fbd3108606fd6864d3, i32 55)
  %83 = call i1 @_FortranAioOutputInteger32(ptr %82, i32 %.066.lcssa)
  %84 = call i32 @_FortranAioEndIoStatement(ptr %82)
  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 {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #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}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
