import java.util.Arrays;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
  public static void main(String... args){
    int[] t = new int[4];
    FastScanner fs = new FastScanner();
    for(int i = 0;i<4;i++){t[i] = fs.nextInt(); }

      if(t[0] < t[2] && t[1] < t[2] || t[2] < t[0] && t[3] < t[0]) System.out.println("0");
      else{
        Arrays.sort(t);
        System.out.println(t[2]-t[1]);
      }
  }
}
class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine(){
			String line = "";
			try{
				line = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return line;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	} import java.util.Arrays; Arrays java.util import java.io.BufferedReader; BufferedReader java.io import java.io.FileNotFoundException; FileNotFoundException java.io import java.io.FileReader; FileReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.StringTokenizer; StringTokenizer java.util class Main{
  public static void main(String... args){
    int[] t = new int[4];
    FastScanner fs = new FastScanner();
    for(int i = 0;i<4;i++){t[i] = fs.nextInt(); }

      if(t[0] < t[2] && t[1] < t[2] || t[2] < t[0] && t[3] < t[0]) System.out.println("0");
      else{
        Arrays.sort(t);
        System.out.println(t[2]-t[1]);
      }
  }
} Main public static void main(String... args){
    int[] t = new int[4];
    FastScanner fs = new FastScanner();
    for(int i = 0;i<4;i++){t[i] = fs.nextInt(); }

      if(t[0] < t[2] && t[1] < t[2] || t[2] < t[0] && t[3] < t[0]) System.out.println("0");
      else{
        Arrays.sort(t);
        System.out.println(t[2]-t[1]);
      }
  } main {
    int[] t = new int[4];
    FastScanner fs = new FastScanner();
    for(int i = 0;i<4;i++){t[i] = fs.nextInt(); }

      if(t[0] < t[2] && t[1] < t[2] || t[2] < t[0] && t[3] < t[0]) System.out.println("0");
      else{
        Arrays.sort(t);
        System.out.println(t[2]-t[1]);
      }
  } int[] t = new int[4]; t new int[4] 4 FastScanner fs = new FastScanner(); fs new FastScanner() for(int i = 0;i<4;i++){t[i] = fs.nextInt(); } int i = 0; int i = 0; i 0 i<4 i 4 i++ i++ i {t[i] = fs.nextInt(); } {t[i] = fs.nextInt(); } t[i] = fs.nextInt() t[i] t i fs.nextInt() fs.nextInt fs if(t[0] < t[2] && t[1] < t[2] || t[2] < t[0] && t[3] < t[0]) System.out.println("0");
      else{
        Arrays.sort(t);
        System.out.println(t[2]-t[1]);
      } t[0] < t[2] && t[1] < t[2] || t[2] < t[0] && t[3] < t[0] t[0] < t[2] && t[1] < t[2] t[0] < t[2] t[0] t 0 t[2] t 2 t[1] < t[2] t[1] t 1 t[2] t 2 t[2] < t[0] && t[3] < t[0] t[2] < t[0] t[2] t 2 t[0] t 0 t[3] < t[0] t[3] t 3 t[0] t 0 System.out.println("0") System.out.println System.out System System.out "0" {
        Arrays.sort(t);
        System.out.println(t[2]-t[1]);
      } Arrays.sort(t) Arrays.sort Arrays t System.out.println(t[2]-t[1]) System.out.println System.out System System.out t[2]-t[1] t[2] t 2 t[1] t 1 String... args args class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine(){
			String line = "";
			try{
				line = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return line;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	} FastScanner BufferedReader br; br StringTokenizer st; st public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} FastScanner {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} FileNotFoundException e {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				br = new BufferedReader(new FileReader(s));
			} br = new BufferedReader(new FileReader(s)) br new BufferedReader(new FileReader(s)) String s s public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		} FastScanner {
			br = new BufferedReader(new InputStreamReader(System.in));
		} br = new BufferedReader(new InputStreamReader(System.in)) br new BufferedReader(new InputStreamReader(System.in)) String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		} nextToken {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		} while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			} st == null || !st.hasMoreElements() st == null st null !st.hasMoreElements() st.hasMoreElements() st.hasMoreElements st {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			} try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} IOException e {
					// TODO Auto-generated catch block
					e.printStackTrace();
				} e.printStackTrace() e.printStackTrace e {
					st = new StringTokenizer(br.readLine());
				} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st String nextLine(){
			String line = "";
			try{
				line = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return line;
		} nextLine {
			String line = "";
			try{
				line = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return line;
		} String line = ""; line "" try{
				line = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			} catch(IOException e){
				e.printStackTrace();
			} IOException e {
				e.printStackTrace();
			} e.printStackTrace() e.printStackTrace e {
				line = br.readLine();
			} line = br.readLine() line br.readLine() br.readLine br return line; line int nextInt() {
			return Integer.parseInt(nextToken());
		} nextInt {
			return Integer.parseInt(nextToken());
		} return Integer.parseInt(nextToken()); Integer.parseInt(nextToken()) Integer.parseInt Integer nextToken() nextToken long nextLong() {
			return Long.parseLong(nextToken());
		} nextLong {
			return Long.parseLong(nextToken());
		} return Long.parseLong(nextToken()); Long.parseLong(nextToken()) Long.parseLong Long nextToken() nextToken double nextDouble() {
			return Double.parseDouble(nextToken());
		} nextDouble {
			return Double.parseDouble(nextToken());
		} return Double.parseDouble(nextToken()); Double.parseDouble(nextToken()) Double.parseDouble Double nextToken() nextToken
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
  public static void main(String... args){
    int[] t = new int[4];
    FastScanner fs = new FastScanner();
    for(int i = 0;i<4;i++){t[i] = fs.nextInt(); }

      if(t[0] < t[2] && t[1] < t[2] || t[2] < t[0] && t[3] < t[0]) System.out.println("0");
      else{
        Arrays.sort(t);
        System.out.println(t[2]-t[1]);
      }
  }
}
class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		String nextLine(){
			String line = "";
			try{
				line = br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return line;
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}
