import java.io.*; import java.util.*; import java.awt.geom.Point2D; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; public class Main { public static void main(String[] args){ // TODO 自動生成されたメソッド・スタブ 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){ System.out.println(Math.max(x, y)); }else{ if( x1==y1 &&( (x1>0 && x>x1)|| (x1<0 && x1>x) )){ System.out.println(Math.max(x, y)+1); }else{ System.out.println(Math.max(x, y)); } } } }