
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: Int = 1

  while (true) {
    if (list.sliding(2).contains(List(a + i, b + i))) {
      println(i)
      System.exit(0)
    }

    i = i + 1
  }
}