object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(uku, usi) = readLine.trim.split(' ').map(_.toLong)
  println(math.min(killUkuFirst(uku, usi), killUsiFirst(uku, usi)))
  def killUsiFirst(uku: Long, usi: Long): Int = {
    val ukuT = new Team(uku)
    val usiT = new Team(usi)
    var count = 0
    while (ukuT.isAlive && usiT.isAlive){
      usiT.decrease(ukuT.maxVote)
      if (usiT.isAlive){
        ukuT.decrease(usiT.minVote)
        count += 1
        if (ukuT.isAlive) count += 1
      }
    }
    count
  }
  def killUkuFirst(uku: Long, usi: Long): Int = {
    val ukuT = new Team(uku)
    val usiT = new Team(usi)
    var count = 0
    while (ukuT.isAlive && usiT.isAlive){
      usiT.decrease(ukuT.minVote)
      if (usiT.isAlive){
        ukuT.decrease(usiT.maxVote)
        count += 1
        if (ukuT.isAlive) count += 1
      }
    }
    count
  }
  class Team(private val start: Long) {
    private var health: Long = start * 2
    def decrease(vote: Long): Unit = {
      health -= vote
    }
    def maxVote: Long = math.min(start, health)
    def minVote: Long = (health + 1) / 2
    def isAlive: Boolean = health > 0
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
