A, B = [int(i) for i in input().strip().split(' ')] print((A+B*2) // 3 - (A*2+B - 1) // 3)