x, y = map(int,input().split()) x2, y2 = map(int,input().split()) z = max(x, y) if x == y and x2 == y2: z += 1 print(z)