X1, Y1 = map(int,input().split()) X2, Y2 = map(int,input().split()) print(max(X1, Y1) + (X1 == Y1 and X2 == Y2 and X2 < X1))