#!/bin/bash

read in1
a=(${in1// / })
p=$((${a[0]} % 2019))
q=$((${a[1]} % 2019))
x=2018
for ((i=p; i<q; i++)); do
  for ((k=$((i+1)); k<=q; k++)); do
    if [ $(((i*k)%2019)) -lt $x ]; then
      x=$(((i*k)%2019))
      if [ $x -le 1 ]; then
        break 2
      fi
    fi
  done
done
echo $x
