implicit none
integer, parameter :: NMOD = 2019
integer(8) :: l,r
integer(8) :: i,j,maxj
integer(8) :: s,k

read *,l,r

if (r-l+1 >= NMOD) then
   write(*,'(a)') '0'
   stop
endif

s = mod(l*r,NMOD)
maxj = min(r, l+NMOD-1)
do i = l,maxj-1
   do j = i+1, maxj
      k = mod(i*j,NMOD)
      if (k == 0) then
         write(*,'(i0)') k
         stop
      else if (k < s) then
         s = k
      endif
   enddo
enddo

write(*,'(i0)') s
end
; 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.4e1c2b607658c0a8ff652d0723a486c1 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3821/source.f\00"
@_QQcl.286129 = linkonce constant [3 x i8] c"(a)"
@_QQcl.30 = linkonce constant [1 x i8] c"0"
@_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 = alloca i64, align 8
  %3 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.4e1c2b607658c0a8ff652d0723a486c1, i32 7)
  %4 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %1, i32 8)
  %5 = call i1 @_FortranAioInputInteger(ptr %3, ptr nonnull %2, i32 8)
  %6 = call i32 @_FortranAioEndIoStatement(ptr %3)
  %7 = load i64, ptr %2, align 8, !tbaa !3
  %8 = load i64, ptr %1, align 8, !tbaa !3
  %9 = add i64 %7, 1
  %10 = sub i64 %9, %8
  %11 = icmp sgt i64 %10, 2018
  br i1 %11, label %12, label %17

12:                                               ; preds = %0
  %13 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.286129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.4e1c2b607658c0a8ff652d0723a486c1, i32 10)
  %14 = call i1 @_FortranAioOutputAscii(ptr %13, ptr nonnull @_QQcl.30, i64 1)
  %15 = call i32 @_FortranAioEndIoStatement(ptr %13)
  %16 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

17:                                               ; preds = %0
  %18 = mul i64 %8, %7
  %19 = srem i64 %18, 2019
  %20 = add i64 %8, 2018
  %21 = call i64 @llvm.smin.i64(i64 %7, i64 %20)
  %22 = sub i64 %21, %8
  %23 = icmp sgt i64 %22, 0
  br i1 %23, label %.lr.ph.preheader, label %._crit_edge34

.lr.ph.preheader:                                 ; preds = %17, %._crit_edge
  %.031 = phi i64 [ %spec.select, %._crit_edge ], [ %19, %17 ]
  %.01830 = phi i64 [ %38, %._crit_edge ], [ %22, %17 ]
  %.02029 = phi i64 [ %24, %._crit_edge ], [ %8, %17 ]
  %24 = add i64 %.02029, 1
  %25 = sub i64 %21, %.02029
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %34
  %.128 = phi i64 [ %spec.select, %34 ], [ %.031, %.lr.ph.preheader ]
  %.01727 = phi i64 [ %35, %34 ], [ %25, %.lr.ph.preheader ]
  %.01926 = phi i64 [ %36, %34 ], [ %24, %.lr.ph.preheader ]
  %26 = mul i64 %.01926, %.02029
  %27 = srem i64 %26, 2019
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %.lr.ph
  %30 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.4e1c2b607658c0a8ff652d0723a486c1, i32 20)
  %31 = call i1 @_FortranAioOutputInteger64(ptr %30, i64 0)
  %32 = call i32 @_FortranAioEndIoStatement(ptr %30)
  %33 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

34:                                               ; preds = %.lr.ph
  %spec.select = call i64 @llvm.smin.i64(i64 %27, i64 %.128)
  %35 = add nsw i64 %.01727, -1
  %36 = add i64 %.01926, 1
  %37 = icmp sgt i64 %.01727, 1
  br i1 %37, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %34
  %38 = add nsw i64 %.01830, -1
  %39 = icmp sgt i64 %.01830, 1
  br i1 %39, label %.lr.ph.preheader, label %._crit_edge34

._crit_edge34:                                    ; preds = %._crit_edge, %17
  %.0.lcssa = phi i64 [ %19, %17 ], [ %spec.select, %._crit_edge ]
  %40 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.28693029, i64 4, ptr null, i32 -1, ptr nonnull @_QQcl.4e1c2b607658c0a8ff652d0723a486c1, i32 28)
  %41 = call i1 @_FortranAioOutputInteger64(ptr %40, i64 %.0.lcssa)
  %42 = call i32 @_FortranAioEndIoStatement(ptr %40)
  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 @_FortranAioOutputAscii(ptr, ptr, i64) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

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

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