import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int[] n = new int[4];
    
    for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    }
    
    int result = 0;
    if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    }
    System.out.println(result);
  }
} import java.io.*; io.* java public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int[] n = new int[4];
    
    for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    }
    
    int result = 0;
    if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    }
    System.out.println(result);
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int[] n = new int[4];
    
    for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    }
    
    int result = 0;
    if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    }
    System.out.println(result);
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int[] n = new int[4];
    
    for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    }
    
    int result = 0;
    if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    }
    System.out.println(result);
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] data = br.readLine().split(" "); data br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] n = new int[4]; n new int[4] 4 for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    } int i=0; int i=0; i 0 i<4 i 4 i++ i++ i {
      n[i] = Integer.parseInt(data[i]);
    } {
      n[i] = Integer.parseInt(data[i]);
    } n[i] = Integer.parseInt(data[i]) n[i] n i Integer.parseInt(data[i]) Integer.parseInt Integer data[i] data i int result = 0; result 0 if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    } n[0] < n[2] n[0] n 0 n[2] n 2 {
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      } n[1] < n[3] n[1] n 1 n[3] n 3 {
        result = Math.max(n[1] - n[2], 0);
      } result = Math.max(n[1] - n[2], 0) result Math.max(n[1] - n[2], 0) Math.max Math n[1] - n[2] n[1] n 1 n[2] n 2 0 {
        result = n[3]-n[2];
      } result = n[3]-n[2] result n[3]-n[2] n[3] n 3 n[2] n 2 {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    } if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      } n[3] < n[1] n[3] n 3 n[1] n 1 {
        result = Math.max(n[3] -n[0], 0);
      } result = Math.max(n[3] -n[0], 0) result Math.max(n[3] -n[0], 0) Math.max Math n[3] -n[0] n[3] n 3 n[0] n 0 0 {
        result = n[1]-n[0];
      } result = n[1]-n[0] result n[1]-n[0] n[1] n 1 n[0] n 0 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int[] n = new int[4];
    
    for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    }
    
    int result = 0;
    if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    }
    System.out.println(result);
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int[] n = new int[4];
    
    for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    }
    
    int result = 0;
    if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    }
    System.out.println(result);
  }
} Main
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int[] n = new int[4];
    
    for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    }
    
    int result = 0;
    if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    }
    System.out.println(result);
  }
}
