<reponame>kagemeka/atcoder-submissions<filename>jp.atcoder/abc070/abc070_b/9100513.py
import sys

a, b, c, d = map(int, sys.stdin.readline().split())


def main():
    return max(0, min(b, d) - max(a, c))


if __name__ == "__main__":
    ans = main()
    print(ans)

import sys

a, b, c, d = map(int, sys.stdin.readline().split())


def main():
    return max(0, min(b, d) - max(a, c))


if __name__ == "__main__":
    ans = main()
    print(ans)