a,b=map(int,input().split()) c=a+3-a%3-(a+b)%3 print(int((b-c)/3+1) if a<=c else 0)