import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);

        int[] time = new int[101];
        time[a] += 1;
        time[b] += -1;
        time[c] += 1;
        time[d] += -1;
        for (int i = 1; i < 101; i++) time[i] += time[i - 1];

        int cnt = 0;
        for (int i = 0; i < 101; i++) if (time[i] == 2) cnt++;

        System.out.println(cnt);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);

        int[] time = new int[101];
        time[a] += 1;
        time[b] += -1;
        time[c] += 1;
        time[d] += -1;
        for (int i = 1; i < 101; i++) time[i] += time[i - 1];

        int cnt = 0;
        for (int i = 0; i < 101; i++) if (time[i] == 2) cnt++;

        System.out.println(cnt);
    }
} Main public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);

        int[] time = new int[101];
        time[a] += 1;
        time[b] += -1;
        time[c] += 1;
        time[d] += -1;
        for (int i = 1; i < 101; i++) time[i] += time[i - 1];

        int cnt = 0;
        for (int i = 0; i < 101; i++) if (time[i] == 2) cnt++;

        System.out.println(cnt);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);

        int[] time = new int[101];
        time[a] += 1;
        time[b] += -1;
        time[c] += 1;
        time[d] += -1;
        for (int i = 1; i < 101; i++) time[i] += time[i - 1];

        int cnt = 0;
        for (int i = 0; i < 101; i++) if (time[i] == 2) cnt++;

        System.out.println(cnt);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] str = br.readLine().split(" "); str br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int a = Integer.parseInt(str[0]); a Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int b = Integer.parseInt(str[1]); b Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int c = Integer.parseInt(str[2]); c Integer.parseInt(str[2]) Integer.parseInt Integer str[2] str 2 int d = Integer.parseInt(str[3]); d Integer.parseInt(str[3]) Integer.parseInt Integer str[3] str 3 int[] time = new int[101]; time new int[101] 101 time[a] += 1 time[a] time a 1 time[b] += -1 time[b] time b -1 1 time[c] += 1 time[c] time c 1 time[d] += -1 time[d] time d -1 1 for (int i = 1; i < 101; i++) time[i] += time[i - 1]; int i = 1; int i = 1; i 1 i < 101 i 101 i++ i++ i time[i] += time[i - 1]; time[i] += time[i - 1] time[i] time i time[i - 1] time i - 1 i 1 int cnt = 0; cnt 0 for (int i = 0; i < 101; i++) if (time[i] == 2) cnt++; int i = 0; int i = 0; i 0 i < 101 i 101 i++ i++ i if (time[i] == 2) cnt++; if (time[i] == 2) cnt++; time[i] == 2 time[i] time i 2 cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);

        int[] time = new int[101];
        time[a] += 1;
        time[b] += -1;
        time[c] += 1;
        time[d] += -1;
        for (int i = 1; i < 101; i++) time[i] += time[i - 1];

        int cnt = 0;
        for (int i = 0; i < 101; i++) if (time[i] == 2) cnt++;

        System.out.println(cnt);
    }
} public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);

        int[] time = new int[101];
        time[a] += 1;
        time[b] += -1;
        time[c] += 1;
        time[d] += -1;
        for (int i = 1; i < 101; i++) time[i] += time[i - 1];

        int cnt = 0;
        for (int i = 0; i < 101; i++) if (time[i] == 2) cnt++;

        System.out.println(cnt);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        int c = Integer.parseInt(str[2]);
        int d = Integer.parseInt(str[3]);

        int[] time = new int[101];
        time[a] += 1;
        time[b] += -1;
        time[c] += 1;
        time[d] += -1;
        for (int i = 1; i < 101; i++) time[i] += time[i - 1];

        int cnt = 0;
        for (int i = 0; i < 101; i++) if (time[i] == 2) cnt++;

        System.out.println(cnt);
    }
}
