import java.util.Scanner


/**
 * Created by sonetsuyoshi on 2015/12/16.
 */
object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextLong
  val m = sc.nextLong

  def run(): Unit = {
    val l = math.min(n, m / 2)

    val n1 = n - l
    val m1 = m - 2 * l

    val ans = l + m1 / 4

    println(ans)
  }

  run()
}