fun main(args: Array<String>) {
    abc055c()
}

fun abc055c() {
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }

    val scc = Math.min(n, m / 2)
    val cccc = (m - scc * 2) / 4

    val answer = scc + cccc

    println(answer)
}
