Problem:
Score : 200 points

Problem Statement

Alice and Bob are controlling a robot. They each have one switch that controls the robot.

Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.

Bob started holding down his button C second after the start-up, and released his button D second after the start-up.

For how many seconds both Alice and Bob were holding down their buttons?

Constraints

0≤A<B≤100

0≤C<D≤100

All input values are integers.

Input

Input is given from Standard Input in the following format:

A B C D

Output

Print the length of the duration (in seconds) in which both Alice and Bob were holding down their buttons.

Sample Input 1

0 75 25 100

Sample Output 1

50

Alice started holding down her button 0 second after the start-up of the robot, and released her button 75 second after the start-up.

Bob started holding down his button 25 second after the start-up, and released his button 100 second after the start-up.

Therefore, the time when both of them were holding down their buttons, is the 50 seconds from 25 seconds after the start-up to 75 seconds after the start-up.

Sample Input 2

0 33 66 99

Sample Output 2

0

Alice and Bob were not holding their buttons at the same time, so the answer is zero seconds.

Sample Input 3

10 90 20 80

Sample Output 3

60

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramB a = new ProgramB();
            a.main();//実行する

        }

    }

    class ProgramA
    {
        public void main()
        {

            string s = Console.ReadLine();

            if(s[0] == s[2])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }

    class ProgramB
    {
        public void main()
        {

            string[] s = Console.ReadLine().Split(' ');

            if (int.Parse(s[1]) > int.Parse(s[2]))
                Console.WriteLine(Math.Abs(Math.Min(int.Parse(s[1]), int.Parse(s[3])) - Math.Max(int.Parse(s[0]), int.Parse(s[2]))));
            else
                Console.WriteLine("0");

        }
    }

    class ProgramC
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');

            int count4 = 0;
            int count2 = 0;

            for (int i = 0; i < n;i++)
            {
                if (long.Parse(a[i]) % 4 == 0)
                    count4++;
                else if(long.Parse(a[i]) % 2 == 0)
                    count2++;
            }


            if (count4 >= n / 2)
            {
                Console.WriteLine("Yes");
                return;
            }


            if (2 * count4 + count2 >= n)
            {
                Console.WriteLine("Yes");
                return;
            }
            

            Console.WriteLine("No");


        }
    }

    class ProgramD
    {
        public void main()
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(Console.ReadLine());
            string[] a = Console.ReadLine().Split(' ');

            List<int> array = new List<int>();
            int[,] ans = new int[int.Parse(s[0]), int.Parse(s[1])];

            for (int i = 0; i < n; i++)
                for (int j = 0; j < int.Parse(a[i]); j++)
                    array.Add(i + 1);

            int k = 0;
            for (int i = 0; i < int.Parse(s[0]); i++)
                for (int j = 0; j < int.Parse(s[1]); j++)
                {
                    if (i % 2 == 0)
                    {
                        ans[i, j] = array[k];
                    }
                    else
                    {
                        ans[i, int.Parse(s[1])- 1 -j] = array[k];
                    }

                    k++;
                }

            for (int i = 0; i < int.Parse(s[0]); i++)
                for (int j = 0; j < int.Parse(s[1]); j++)
                {
                    Console.Write(ans[i, j]);
                    if( j == int.Parse(s[1]) - 1)
                        Console.WriteLine("");
                    else
                        Console.Write(" ");


                }



        }
    }

}