import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int alicePressSecond = Integer.parseInt(inputNumbers.get(0));
            int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1));
            int bobPressSecond = Integer.parseInt(inputNumbers.get(2));
            int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3));

            int maxPressSecond = bobPressSecond;
            if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            }
            
            int minReleaseSecond = bobReleaseSecond;
            if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            }

            int ans = 0;
            if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.HashSet; HashSet java.util import java.util.List; List java.util import java.util.Set; Set java.util class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int alicePressSecond = Integer.parseInt(inputNumbers.get(0));
            int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1));
            int bobPressSecond = Integer.parseInt(inputNumbers.get(2));
            int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3));

            int maxPressSecond = bobPressSecond;
            if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            }
            
            int minReleaseSecond = bobReleaseSecond;
            if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            }

            int ans = 0;
            if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
} Main public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int alicePressSecond = Integer.parseInt(inputNumbers.get(0));
            int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1));
            int bobPressSecond = Integer.parseInt(inputNumbers.get(2));
            int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3));

            int maxPressSecond = bobPressSecond;
            if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            }
            
            int minReleaseSecond = bobReleaseSecond;
            if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            }

            int ans = 0;
            if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    } main {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int alicePressSecond = Integer.parseInt(inputNumbers.get(0));
            int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1));
            int bobPressSecond = Integer.parseInt(inputNumbers.get(2));
            int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3));

            int maxPressSecond = bobPressSecond;
            if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            }
            
            int minReleaseSecond = bobReleaseSecond;
            if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            }

            int ans = 0;
            if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    } try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int alicePressSecond = Integer.parseInt(inputNumbers.get(0));
            int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1));
            int bobPressSecond = Integer.parseInt(inputNumbers.get(2));
            int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3));

            int maxPressSecond = bobPressSecond;
            if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            }
            
            int minReleaseSecond = bobReleaseSecond;
            if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            }

            int ans = 0;
            if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } IOException | NumberFormatException e {
            e.printStackTrace();
            System.exit(0);
        } e.printStackTrace() e.printStackTrace e System.exit(0) System.exit System 0 catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        } final Exception e {
            e.printStackTrace();
            System.exit(0);
        } e.printStackTrace() e.printStackTrace e System.exit(0) System.exit System 0 {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int alicePressSecond = Integer.parseInt(inputNumbers.get(0));
            int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1));
            int bobPressSecond = Integer.parseInt(inputNumbers.get(2));
            int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3));

            int maxPressSecond = bobPressSecond;
            if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            }
            
            int minReleaseSecond = bobReleaseSecond;
            if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            }

            int ans = 0;
            if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            }

            System.out.println(ans);
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) new BufferedReader(new InputStreamReader(System.in)) List<String> inputNumbers = Arrays.asList(br.readLine().split(" ")); inputNumbers Arrays.asList(br.readLine().split(" ")) Arrays.asList Arrays br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int alicePressSecond = Integer.parseInt(inputNumbers.get(0)); alicePressSecond Integer.parseInt(inputNumbers.get(0)) Integer.parseInt Integer inputNumbers.get(0) inputNumbers.get inputNumbers 0 int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1)); aliceReleaseSecond Integer.parseInt(inputNumbers.get(1)) Integer.parseInt Integer inputNumbers.get(1) inputNumbers.get inputNumbers 1 int bobPressSecond = Integer.parseInt(inputNumbers.get(2)); bobPressSecond Integer.parseInt(inputNumbers.get(2)) Integer.parseInt Integer inputNumbers.get(2) inputNumbers.get inputNumbers 2 int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3)); bobReleaseSecond Integer.parseInt(inputNumbers.get(3)) Integer.parseInt Integer inputNumbers.get(3) inputNumbers.get inputNumbers 3 int maxPressSecond = bobPressSecond; maxPressSecond bobPressSecond if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            } alicePressSecond > bobPressSecond alicePressSecond bobPressSecond {
                maxPressSecond = alicePressSecond;
            } maxPressSecond = alicePressSecond maxPressSecond alicePressSecond int minReleaseSecond = bobReleaseSecond; minReleaseSecond bobReleaseSecond if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            } aliceReleaseSecond < bobReleaseSecond aliceReleaseSecond bobReleaseSecond {
                minReleaseSecond = aliceReleaseSecond;
            } minReleaseSecond = aliceReleaseSecond minReleaseSecond aliceReleaseSecond int ans = 0; ans 0 if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            } maxPressSecond < minReleaseSecond maxPressSecond minReleaseSecond {
                ans = minReleaseSecond - maxPressSecond;
            } ans = minReleaseSecond - maxPressSecond ans minReleaseSecond - maxPressSecond minReleaseSecond maxPressSecond System.out.println(ans) System.out.println System.out System System.out ans final String[] args args
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputNumbers = Arrays.asList(br.readLine().split(" "));
            int alicePressSecond = Integer.parseInt(inputNumbers.get(0));
            int aliceReleaseSecond = Integer.parseInt(inputNumbers.get(1));
            int bobPressSecond = Integer.parseInt(inputNumbers.get(2));
            int bobReleaseSecond = Integer.parseInt(inputNumbers.get(3));

            int maxPressSecond = bobPressSecond;
            if (alicePressSecond > bobPressSecond) {
                maxPressSecond = alicePressSecond;
            }
            
            int minReleaseSecond = bobReleaseSecond;
            if (aliceReleaseSecond < bobReleaseSecond) {
                minReleaseSecond = aliceReleaseSecond;
            }

            int ans = 0;
            if (maxPressSecond < minReleaseSecond) {
                ans = minReleaseSecond - maxPressSecond;
            }

            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}