import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextLong // S
  val m = sc.nextLong // c

  val x = (n * 2 + m) / 4

  val res = if(n <= x) x else m/2

  println(res)
}