a,b=map(int,input().split()) c=0 while a>=1 and b>=1: a-=1 b-=1 c+=2 if a==0 and b==0: c-=1 print(c)