#!/usr/bin/env python3
twos, threes = map(int, input().split())

def greedily_take_hundred(already_taken=0):
    global twos, threes
    if already_taken == 100:
        return True
    elif already_taken < 96 and threes >= 2:
        threes -= 2
        return greedily_take_hundred(already_taken + 6)
    elif twos >= 1:
        twos -= 1
        return greedily_take_hundred(already_taken + 2)
    return False

count = 0
while greedily_take_hundred():
    count += 1

print(count)
