a,b = map(int,input().split()) s = 2*a+b e = a + 2*b x = 3 if s % 3 == 0 : x = 0 s1 = s - s % 3 + x e1 = e - e % 3 print((e1-s1)//3+1)