import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
import std.format;

void main()
{
  int[101] imos;
  auto d = readln.chomp.split.map!(to!int);
  imos[d[0]]++;
  imos[d[1]]--;
  imos[d[2]]++;
  imos[d[3]]--;
  int cnt = 0;
  int ite = 0;
  for (int i = 0; i <= 100; ++i) {
    ite += imos[i];
    if (ite == 2) {
      ++cnt;
    }
  }
  writeln = cnt;
}