A = int(input()) B = int(input()) count = 0 for i in range(A,B+1): ave = (A+B+i)/3 if type(ave) == int: count += 1 print(count)