x,y = map(int,input().split()) z,w = map(int,input().split()) ans = max(x,y) if x == y and z == w and abs(x) > abs(z) and x*z > 0: ans += 1 if x == -y and z == -w and abs(x) > abs(z) and x*z > 0: ans += 1 print(ans)