# -*- coding: utf-8 -*- """ No.208 王将 https://yukicoder.me/problems/no/208 """ import sys from sys import stdin input = stdin.readline def main(args): x, y = map(int, input().split()) ox, oy = map(int, input().split()) ans = max(x, y) if x == y and ox == oy and x > ox: ans = max(x, y) + 1 print(ans) if __name__ == '__main__': main(sys.argv[1:])