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

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto xs = readints();
    int a = xs[0], b = xs[1], c = xs[2], d = xs[3];

    int ans = 0;
    for (int i = 0; i <= 100; i++) {
        if (a <= i && i <= b && c <= i && i <= d) {
            ans++;
        }
    }
    writeln(max(0, ans - 1));
}
