import java.io.*;
import java.util.*;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int[] time = new int[101];
        int a = in.nextInt();
        int b = in.nextInt();
        for (int i = a; i < b; i++) {
            time[i]++;
        }
        int c = in.nextInt();
        int d = in.nextInt();
        for (int i = c; i < d; i++) {
            time[i]++;
        }
        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(time[i] == 2) cnt++;
        }
        System.out.println(cnt);
    }
}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int[] time = new int[101];
        int a = in.nextInt();
        int b = in.nextInt();
        for (int i = a; i < b; i++) {
            time[i]++;
        }
        int c = in.nextInt();
        int d = in.nextInt();
        for (int i = c; i < d; i++) {
            time[i]++;
        }
        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(time[i] == 2) cnt++;
        }
        System.out.println(cnt);
    }
} Main static ContestScanner in; in static Writer out; out public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } main {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } Main main = new Main(); main new Main() try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } IOException e {
            e.printStackTrace();
        } e.printStackTrace() e.printStackTrace e {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } in = new ContestScanner() in new ContestScanner() out = new Writer() out new Writer() main.solve() main.solve main out.close() out.close out in.close() in.close in String[] args args void solve() throws IOException {
        int[] time = new int[101];
        int a = in.nextInt();
        int b = in.nextInt();
        for (int i = a; i < b; i++) {
            time[i]++;
        }
        int c = in.nextInt();
        int d = in.nextInt();
        for (int i = c; i < d; i++) {
            time[i]++;
        }
        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(time[i] == 2) cnt++;
        }
        System.out.println(cnt);
    } solve {
        int[] time = new int[101];
        int a = in.nextInt();
        int b = in.nextInt();
        for (int i = a; i < b; i++) {
            time[i]++;
        }
        int c = in.nextInt();
        int d = in.nextInt();
        for (int i = c; i < d; i++) {
            time[i]++;
        }
        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(time[i] == 2) cnt++;
        }
        System.out.println(cnt);
    } int[] time = new int[101]; time new int[101] 101 int a = in.nextInt(); a in.nextInt() in.nextInt in int b = in.nextInt(); b in.nextInt() in.nextInt in for (int i = a; i < b; i++) {
            time[i]++;
        } int i = a; int i = a; i a i < b i b i++ i++ i {
            time[i]++;
        } {
            time[i]++;
        } time[i]++ time[i] time i int c = in.nextInt(); c in.nextInt() in.nextInt in int d = in.nextInt(); d in.nextInt() in.nextInt in for (int i = c; i < d; i++) {
            time[i]++;
        } int i = c; int i = c; i c i < d i d i++ i++ i {
            time[i]++;
        } {
            time[i]++;
        } time[i]++ time[i] time i 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++;
        } 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 class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
} MultiSet @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;} get {return containsKey(key)?super.get(key):0L;} return containsKey(key)?super.get(key):0L; containsKey(key)?super.get(key):0L containsKey(key) containsKey key super.get(key) super.get super key 0L Object key key public void add(T key,long v){put(key,get(key)+v);} add {put(key,get(key)+v);} put(key,get(key)+v) put key get(key)+v get(key) get key v T key key long v v public void add(T key){put(key,get(key)+1);} add {put(key,get(key)+1);} put(key,get(key)+1) put key get(key)+1 get(key) get key 1 T key key public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);} sub {final long v=get(key);if(v==1)remove(key);else put(key,v-1);} final long v=get(key); v get(key) get key if(v==1)remove(key);else put(key,v-1); v==1 v 1 remove(key) remove key put(key,v-1) put key v-1 v 1 T key key public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;} merge {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;} MultiSet<T>s s l; l if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;} this.size()<set.size() this.size() this.size this set.size() set.size set {s=this;l=set;} s=this s this l=set l set {s=set;l=this;} s=set s set l=this l this for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue()); Entry<T,Long>e s.entrySet() s.entrySet s l.add(e.getKey(),e.getValue()); l.add(e.getKey(),e.getValue()) l.add l e.getKey() e.getKey e e.getValue() e.getValue e return l; l MultiSet<T> set set HashMap class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
} Writer public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));} Writer {super(new BufferedWriter(new FileWriter(filename)));} super(new BufferedWriter(new FileWriter(filename))) super new BufferedWriter(new FileWriter(filename)) String filename filename public Writer()throws IOException{super(System.out);} Writer {super(System.out);} super(System.out) super System.out System System.out PrintWriter class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
} ContestScanner private BufferedReader in; in private int c=-2; c -2 2 public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));} ContestScanner {in=new BufferedReader(new InputStreamReader(System.in));} in=new BufferedReader(new InputStreamReader(System.in)) in new BufferedReader(new InputStreamReader(System.in)) public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));} ContestScanner {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));} in=new BufferedReader(new InputStreamReader(new FileInputStream(filename))) in new BufferedReader(new InputStreamReader(new FileInputStream(filename))) String filename filename public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    } nextToken {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    } StringBuilder sb=new StringBuilder(); sb new StringBuilder() while((c=in.read())!=-1&&Character.isWhitespace(c)); (c=in.read())!=-1&&Character.isWhitespace(c) (c=in.read())!=-1 (c=in.read()) c in.read() in.read in -1 1 Character.isWhitespace(c) Character.isWhitespace Character c while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();} c!=-1&&!Character.isWhitespace(c) c!=-1 c -1 1 !Character.isWhitespace(c) Character.isWhitespace(c) Character.isWhitespace Character c {sb.append((char)c);c=in.read();} sb.append((char)c) sb.append sb (char)c c=in.read() c in.read() in.read in return sb.toString(); sb.toString() sb.toString sb public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    } readLine {
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    } StringBuilder sb=new StringBuilder(); sb new StringBuilder() if(c==-2)c=in.read(); c==-2 c -2 2 c=in.read() c in.read() in.read in while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();} c!=-1&&c!='\n'&&c!='\r' c!=-1&&c!='\n'&&c!='\r' c!=-1 c -1 1 c!='\n' c '\n' c!='\r' c '\r' {sb.append((char)c);c=in.read();} sb.append((char)c) sb.append sb (char)c c=in.read() c in.read() in.read in return sb.toString(); sb.toString() sb.toString sb public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());} nextLong {return Long.parseLong(nextToken());} return Long.parseLong(nextToken()); Long.parseLong(nextToken()) Long.parseLong Long nextToken() nextToken public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();} nextInt {return(int)nextLong();} return(int)nextLong(); (int)nextLong() nextLong public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());} nextDouble {return Double.parseDouble(nextToken());} return Double.parseDouble(nextToken()); Double.parseDouble(nextToken()) Double.parseDouble Double nextToken() nextToken public void close() throws IOException {in.close();} close {in.close();} in.close() in.close in Closeable public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int[] time = new int[101];
        int a = in.nextInt();
        int b = in.nextInt();
        for (int i = a; i < b; i++) {
            time[i]++;
        }
        int c = in.nextInt();
        int d = in.nextInt();
        for (int i = c; i < d; i++) {
            time[i]++;
        }
        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(time[i] == 2) cnt++;
        }
        System.out.println(cnt);
    }
} public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int[] time = new int[101];
        int a = in.nextInt();
        int b = in.nextInt();
        for (int i = a; i < b; i++) {
            time[i]++;
        }
        int c = in.nextInt();
        int d = in.nextInt();
        for (int i = c; i < d; i++) {
            time[i]++;
        }
        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(time[i] == 2) cnt++;
        }
        System.out.println(cnt);
    }
} Main
import java.io.*;
import java.util.*;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int[] time = new int[101];
        int a = in.nextInt();
        int b = in.nextInt();
        for (int i = a; i < b; i++) {
            time[i]++;
        }
        int c = in.nextInt();
        int d = in.nextInt();
        for (int i = c; i < d; i++) {
            time[i]++;
        }
        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(time[i] == 2) cnt++;
        }
        System.out.println(cnt);
    }
}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}
