# -*- coding: utf-8 -*-
"""
Created on Wed Jun  5 09:53:48 2019

@author: Enya
"""

input_code = input()
A = int(input_code.split()[0])
P = int(input_code.split()[1])

X = A*3 + P
N = 0

if A>3:
    N = A//3

else:
    N = 0
    
print(N)