a, b = map(int, raw_input().split()) c, d = map(int, raw_input().split()) print max(a, b)+2 if a==c==0 or b==d==0 else max(a,b)