void main() {
    int[] tmp = readln.split.to!(int[]);
    int a = tmp[0], b = tmp[1], c = tmp[2], d = tmp[3];
    int[] time = new int[101];
    ++time[a], --time[b], ++time[c], --time[d];
    foreach (i; 1 .. 101) {
        time[i] += time[i-1];
    }
    time.count(2).writeln;
}

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