import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int x=sc.nextInt(),y=sc.nextInt(),x2=sc.nextInt(),y2=sc.nextInt(); sc.close(); if(x==y&&x2==y2&&x>x2) System.out.print(x+1); else if(x>y) System.out.print(x); else System.out.print(y); } }