
object Main extends App {
  var list = List[Int](1)
  (2 to 999).foreach { i =>
    list :+= (i + list.last)
  }

  val Array(a, b) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  var i: Long = 1

 // println(list.zipWithIndex)

  while (true) {
    if (list.zipWithIndex.exists(_._1 == a + i)) {
      //println(list.zipWithIndex.find(_._1 == a + i).get._2 + 1)
      //println(list(list.zipWithIndex.find(_._1 == a + i).get._2 + 1))

      if (list(list.zipWithIndex.find(_._1 == a + i).get._2 + 1) == b + i) {
        println(i)
        System.exit(0)
      }

    }

    i = i + 1

  }
}