#208.py tx,ty = input().split() hx,hy = input().split() tx,ty = int(tx),int(ty) hx,hy = int(hx),int(hy) x,y = 0,0 lx,ly = -1,-1 c = 0 lx = tx-x ly = ty-y if(lx == ly): if(hx-hy == 0): if(hx>tx): c=tx else: c=tx+1 else: c=tx if(lx < ly): c=ly if(lx > ly): c=lx print(c)