import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int l=in.nextInt();
		int r=in.nextInt();
		if(r-l>2019)
		{
			System.out.println(0);
		}
		else
		{
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		}
	}
}
	 import java.util.*; util.* java import java.io.*; io.* java public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int l=in.nextInt();
		int r=in.nextInt();
		if(r-l>2019)
		{
			System.out.println(0);
		}
		else
		{
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		}
	}
} Main public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int l=in.nextInt();
		int r=in.nextInt();
		if(r-l>2019)
		{
			System.out.println(0);
		}
		else
		{
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		}
	} main {
		Scanner in=new Scanner(System.in);
		int l=in.nextInt();
		int r=in.nextInt();
		if(r-l>2019)
		{
			System.out.println(0);
		}
		else
		{
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		}
	} Scanner in=new Scanner(System.in); in new Scanner(System.in) int l=in.nextInt(); l in.nextInt() in.nextInt in int r=in.nextInt(); r in.nextInt() in.nextInt in if(r-l>2019)
		{
			System.out.println(0);
		}
		else
		{
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		} r-l>2019 r-l r l 2019 {
			System.out.println(0);
		} System.out.println(0) System.out.println System.out System System.out 0 {
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		} int p=l%2019; p l%2019 l 2019 r=r%2019 r r%2019 r 2019 if(r<p)
			{
				r=r+2019;
			} r<p r p {
				r=r+2019;
			} r=r+2019 r r+2019 r 2019 int min=2019; min 2019 for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			} int i=p; int i=p; i p i<=r i r i++ i++ i {
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			} {
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			} for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				} int j=i+1; int j=i+1; j i+1 i 1 j<=r j r j++ j++ j {
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				} {
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				} int ans=(i*j)%2019; ans (i*j)%2019 (i*j) i j 2019 if(ans<min)
					{
						min=ans;
					} ans<min ans min {
						min=ans;
					} min=ans min ans System.out.println(min) System.out.println System.out System System.out min String [] Args Args public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int l=in.nextInt();
		int r=in.nextInt();
		if(r-l>2019)
		{
			System.out.println(0);
		}
		else
		{
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		}
	}
} public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int l=in.nextInt();
		int r=in.nextInt();
		if(r-l>2019)
		{
			System.out.println(0);
		}
		else
		{
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		}
	}
} Main
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int l=in.nextInt();
		int r=in.nextInt();
		if(r-l>2019)
		{
			System.out.println(0);
		}
		else
		{
			int p=l%2019;
			r=r%2019;
			if(r<p)
			{
				r=r+2019;
			}
			int min=2019;
			for(int i=p;i<=r;i++)
			{
				for(int j=i+1;j<=r;j++)
				{
					int ans=(i*j)%2019;
					if(ans<min)
					{
						min=ans;
					}
				}
			}
			System.out.println(min);
		}
	}
}
	