object Main extends App {
  import scala.io.StdIn._
  val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
  var top = 0L
  var right = 0L
  var bottom = 0L
  var left = 0L
  println(search())
  def search(a: Long = 1, b: Long = 2, count: Int = 0): Int = {
    if (left <= x && x <= right && bottom <= y && y <= top) return count % 3 + 1
    (count % 4) match {
      case 0 ⇒
        right += a
        search(b, a + b, count + 1)
      case 1 ⇒
        top += a
        search(b, a + b, count + 1)
      case 2 ⇒
        left -= a
        search(b, a + b, count + 1)
      case 3 ⇒
        bottom -= a
        search(b, a + b, count + 1)
      case _ ⇒ ???
    }
  }
}
