"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let S = parseInt(arg[0].split(" ")[0]);
    let C = Math.floor(parseInt(arg[0].split(" ")[1]) / 2);
    
    let cnt = 0;
    
    if(S > C) {
        console.log(C);
    } else {
        C -= S;
        console.log(S + Math.floor(C / 2))
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));