//
// Created by Brigt Håvardstun on 30/09/2021.
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace  std;
int solve(long int x, long int y){
    long int y_pairs = y / 2;
    long sum = 0;
    long nr_100s = 0;
    while (y_pairs > 0){
        sum += 6;
        y_pairs--;
        if(sum >= 96){
            if(x >= 2){
                nr_100s++;
                x -= 2;
                sum = 0;
            } else {
                break;
            }
        }
    }

    while(x > 0){
        sum += 2;
        x--;
        if(sum == 100){
            nr_100s++;
            sum = 0;
        }
    }
    cout << nr_100s << endl;


    return nr_100s;
}

int main(){
    // Read input
    long int  x, y;
    scanf("%ld %ld", &x, &y);
    solve(x, y);
    return 0;
}
