import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range, std.functional;

void main() {
    auto tmp = readln.split.to!(int[]);
    writeln(max(0, min(tmp[3], tmp[1]) - max(tmp[2], tmp[0])));
}