a,b=map(int,input().split()) n=a+b c=[] if a>b: for i in range(a+b): if i%2==0: if a>0: c.append("a") a-=1 else: if b>0: c.append("b") b-=1 else: c.append("a") break elif a==b: for i in range(a+b): if i%2==0: c.append("a") a-=1 else: c.append("b") b-=1 elif a0: c.append("b") b-=1 else: if a>0: c.append("a") a-=1 else: c.append("b") break ans=0 for i in range(1,n): if c[i]!=c[i-1]: ans+=1 print(ans)