import Foundation

let array = readLine()!.componentsSeparatedByString(" ")
let l = Int(array[0])!
let r = Int(array[1])!

var iMod2019 = l % 2019

if l < 2019 {
  if 2019 <= r {
    print(0)
  } else if 2019 < l * (l + 1) {
    print((l * (l + 1)) % 2019)
  } else {
    print((l * (l + 1)) % 2019)
  }
} else {
  if iMod2019 == 0 {
    print(0)
  } else {
    if (l + 2019 - iMod2019) <= r {
      print(0)
    } else {
      print((l * (l + 1)) % 2019)
    }
  }
}