a=int(input())
b=int(input())
s1=0;s2=0;tot=0
for i in range(10000):
	if a<b:
		a+=1
		s1+=1
		if a!=b:
			b-=1
			s2+=1
		elif a==b:
			tot=s1+s2
			break
	continue
	if a>b:
		b+=1
		s2+=1
		if b!=a:
			a-=1
			s1+=1
		elif a==b:
			tot=s1+s2
			break
print(tot)
