open System

// 2000 2100
// 2000 91 -> 0

// 2020 2040
// 1 21 -> 1 * 2 

// 1000 2018 -> 1000 * 1001

let S = stdin.ReadLine().Split() |> Array.map int
let i = S.[0] % 2019
let j = S.[1] % 2019

let ans = if i >= j then 0 else i * (i + 1)

ans |> stdout.WriteLine