import java.io.*; import java.util.*; class Main { public static void out (Object o) { System.out.println(o); } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line1 = br.readLine().split(" "); String[] line2 = br.readLine().split(" "); int x = Integer.parseInt(line1[0]); int y = Integer.parseInt(line1[1]); int x2 = Integer.parseInt(line2[0]); int y2 = Integer.parseInt(line2[1]); int ans = Math.max(x , y); out(x == y && x2 == y2 && x2 < x ? ans + 1 : ans); } }