import std.algorithm,
       std.string,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] abcd = readln.chomp.split.to!(int[]);
  int a = abcd[0],
      b = abcd[1],
      c = abcd[2],
      d = abcd[3];

  if (a < c) {
    if (c < b) {
      if (b < d) {
        writeln(b - c);
      } else {
        writeln(d - c);
      }
    } else {
      writeln(0);
    }
  } else {
    if (d < a) {
      if (d < b) {
        writeln(d - a);
      } else {
        writeln(b - a);
      }
    } else {
      writeln(0);
    }
  }
}
