import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    String[] tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int start = 0;
    int end = 0;

    if (a < c) {
      start = c;
    } else {
      start = a;
    }

    if (b < d) {
      end = b;
    } else {
      end = d;
    }

    int result = end - start;
    if (result < 0) {
      result = 0;
    }
    System.out.print(result);

  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

  public static void main(String[] args) {

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    String[] tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int start = 0;
    int end = 0;

    if (a < c) {
      start = c;
    } else {
      start = a;
    }

    if (b < d) {
      end = b;
    } else {
      end = d;
    }

    int result = end - start;
    if (result < 0) {
      result = 0;
    }
    System.out.print(result);

  }
} Main public static void main(String[] args) {

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    String[] tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int start = 0;
    int end = 0;

    if (a < c) {
      start = c;
    } else {
      start = a;
    }

    if (b < d) {
      end = b;
    } else {
      end = d;
    }

    int result = end - start;
    if (result < 0) {
      result = 0;
    }
    System.out.print(result);

  } main {

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    String[] tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int start = 0;
    int end = 0;

    if (a < c) {
      start = c;
    } else {
      start = a;
    }

    if (b < d) {
      end = b;
    } else {
      end = d;
    }

    int result = end - start;
    if (result < 0) {
      result = 0;
    }
    System.out.print(result);

  } int a = 0; a 0 int b = 0; b 0 int c = 0; c 0 int d = 0; d 0 String[] tmp = null; tmp null try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    } IOException e {
      e.printStackTrace();
      System.exit(1);
    } e.printStackTrace() e.printStackTrace e System.exit(1) System.exit System 1 {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) tmp = br.readLine().split("\\s") tmp br.readLine().split("\\s") br.readLine().split br.readLine() br.readLine br "\\s" a = Integer.parseInt(tmp[0]) a Integer.parseInt(tmp[0]) Integer.parseInt Integer tmp[0] tmp 0 b = Integer.parseInt(tmp[1]) b Integer.parseInt(tmp[1]) Integer.parseInt Integer tmp[1] tmp 1 c = Integer.parseInt(tmp[2]) c Integer.parseInt(tmp[2]) Integer.parseInt Integer tmp[2] tmp 2 d = Integer.parseInt(tmp[3]) d Integer.parseInt(tmp[3]) Integer.parseInt Integer tmp[3] tmp 3 int start = 0; start 0 int end = 0; end 0 if (a < c) {
      start = c;
    } else {
      start = a;
    } a < c a c {
      start = c;
    } start = c start c {
      start = a;
    } start = a start a if (b < d) {
      end = b;
    } else {
      end = d;
    } b < d b d {
      end = b;
    } end = b end b {
      end = d;
    } end = d end d int result = end - start; result end - start end start if (result < 0) {
      result = 0;
    } result < 0 result 0 {
      result = 0;
    } result = 0 result 0 System.out.print(result) System.out.print System.out System System.out result String[] args args public class Main {

  public static void main(String[] args) {

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    String[] tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int start = 0;
    int end = 0;

    if (a < c) {
      start = c;
    } else {
      start = a;
    }

    if (b < d) {
      end = b;
    } else {
      end = d;
    }

    int result = end - start;
    if (result < 0) {
      result = 0;
    }
    System.out.print(result);

  }
} public class Main {

  public static void main(String[] args) {

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    String[] tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int start = 0;
    int end = 0;

    if (a < c) {
      start = c;
    } else {
      start = a;
    }

    if (b < d) {
      end = b;
    } else {
      end = d;
    }

    int result = end - start;
    if (result < 0) {
      result = 0;
    }
    System.out.print(result);

  }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    String[] tmp = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
      tmp = br.readLine().split("\\s");
      a = Integer.parseInt(tmp[0]);
      b = Integer.parseInt(tmp[1]);
      c = Integer.parseInt(tmp[2]);
      d = Integer.parseInt(tmp[3]);
    } catch (IOException e) {
      e.printStackTrace();
      System.exit(1);
    }

    int start = 0;
    int end = 0;

    if (a < c) {
      start = c;
    } else {
      start = a;
    }

    if (b < d) {
      end = b;
    } else {
      end = d;
    }

    int result = end - start;
    if (result < 0) {
      result = 0;
    }
    System.out.print(result);

  }
}
