let solve n m =
    if (n * 2) >= m
    then m / 2
    else n + (m - 2 * n) / 4;;

let () = 
    let (n, m) = Scanf.scanf "%d %d" (fun n m -> n, m) in
    print_int (solve n m);
    print_newline ();;
