
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {

    String Name;
    int SV;
    int EV;
    boolean T;

    Main(String Name, int SV, int EV, boolean T) {
        this.Name = Name;
        this.SV = SV;
        this.EV = EV;
        this.T = T;
    }

    public static void main(String[] args) throws IOException {
        Scanner Input = new Scanner(System.in);
        int A = Input.nextInt();
        int B = Input.nextInt();
        Main B1 = new Main("B1", A, B, false);
        int C = Input.nextInt();
        int D = Input.nextInt();
        Main B2 = new Main("B2", C, D, false);
        int Count = 0;
        for (int I = 0; I <= 100; I++) {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        }
        System.out.println(Count);

    }
} import java.io.*; io.* java import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util class Main {

    String Name;
    int SV;
    int EV;
    boolean T;

    Main(String Name, int SV, int EV, boolean T) {
        this.Name = Name;
        this.SV = SV;
        this.EV = EV;
        this.T = T;
    }

    public static void main(String[] args) throws IOException {
        Scanner Input = new Scanner(System.in);
        int A = Input.nextInt();
        int B = Input.nextInt();
        Main B1 = new Main("B1", A, B, false);
        int C = Input.nextInt();
        int D = Input.nextInt();
        Main B2 = new Main("B2", C, D, false);
        int Count = 0;
        for (int I = 0; I <= 100; I++) {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        }
        System.out.println(Count);

    }
} Main String Name; Name int SV; SV int EV; EV boolean T; T Main(String Name, int SV, int EV, boolean T) {
        this.Name = Name;
        this.SV = SV;
        this.EV = EV;
        this.T = T;
    } Main {
        this.Name = Name;
        this.SV = SV;
        this.EV = EV;
        this.T = T;
    } this.Name = Name this.Name this this.Name Name this.SV = SV this.SV this this.SV SV this.EV = EV this.EV this this.EV EV this.T = T this.T this this.T T String Name Name int SV SV int EV EV boolean T T public static void main(String[] args) throws IOException {
        Scanner Input = new Scanner(System.in);
        int A = Input.nextInt();
        int B = Input.nextInt();
        Main B1 = new Main("B1", A, B, false);
        int C = Input.nextInt();
        int D = Input.nextInt();
        Main B2 = new Main("B2", C, D, false);
        int Count = 0;
        for (int I = 0; I <= 100; I++) {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        }
        System.out.println(Count);

    } main {
        Scanner Input = new Scanner(System.in);
        int A = Input.nextInt();
        int B = Input.nextInt();
        Main B1 = new Main("B1", A, B, false);
        int C = Input.nextInt();
        int D = Input.nextInt();
        Main B2 = new Main("B2", C, D, false);
        int Count = 0;
        for (int I = 0; I <= 100; I++) {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        }
        System.out.println(Count);

    } Scanner Input = new Scanner(System.in); Input new Scanner(System.in) int A = Input.nextInt(); A Input.nextInt() Input.nextInt Input int B = Input.nextInt(); B Input.nextInt() Input.nextInt Input Main B1 = new Main("B1", A, B, false); B1 new Main("B1", A, B, false) int C = Input.nextInt(); C Input.nextInt() Input.nextInt Input int D = Input.nextInt(); D Input.nextInt() Input.nextInt Input Main B2 = new Main("B2", C, D, false); B2 new Main("B2", C, D, false) int Count = 0; Count 0 for (int I = 0; I <= 100; I++) {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        } int I = 0; int I = 0; I 0 I <= 100 I 100 I++ I++ I {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        } {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        } if (I == B1.SV) {
                B1.T = true;
            } I == B1.SV I B1.SV B1 B1.SV {
                B1.T = true;
            } B1.T = true B1.T B1 B1.T true if (I == B2.SV) {
                B2.T = true;
            } I == B2.SV I B2.SV B2 B2.SV {
                B2.T = true;
            } B2.T = true B2.T B2 B2.T true if (I == B1.EV) {
                B1.T = false;
            } I == B1.EV I B1.EV B1 B1.EV {
                B1.T = false;
            } B1.T = false B1.T B1 B1.T false if (I == B2.EV) {
                B2.T = false;
            } I == B2.EV I B2.EV B2 B2.EV {
                B2.T = false;
            } B2.T = false B2.T B2 B2.T false if(B1.T && B2.T){
            Count++;} B1.T && B2.T B1.T B1 B1.T B2.T B2 B2.T {
            Count++;} Count++ Count System.out.println(Count) System.out.println System.out System System.out Count String[] args args

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {

    String Name;
    int SV;
    int EV;
    boolean T;

    Main(String Name, int SV, int EV, boolean T) {
        this.Name = Name;
        this.SV = SV;
        this.EV = EV;
        this.T = T;
    }

    public static void main(String[] args) throws IOException {
        Scanner Input = new Scanner(System.in);
        int A = Input.nextInt();
        int B = Input.nextInt();
        Main B1 = new Main("B1", A, B, false);
        int C = Input.nextInt();
        int D = Input.nextInt();
        Main B2 = new Main("B2", C, D, false);
        int Count = 0;
        for (int I = 0; I <= 100; I++) {
            if (I == B1.SV) {
                B1.T = true;
            }
            if (I == B2.SV) {
                B2.T = true;
            }
            if (I == B1.EV) {
                B1.T = false;
            }
            if (I == B2.EV) {
                B2.T = false;
            }
            if(B1.T && B2.T){
            Count++;}
        }
        System.out.println(Count);

    }
}
