import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); int x1 = sc.nextInt(); int y1 = sc.nextInt(); if (x == y && x1 == y1) { System.out.println(x + 1); } else { System.out.println(Math.max(x, y)); } } }