import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int a = Integer.parseInt(tokens[0].substring(0, 3));
		int b = Integer.parseInt(tokens[1].substring(0, 3));
		int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0));
		int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0));
		int result = b - a + 1;
		if (A > min) {
			result -= 1;
		}
		if (B < max) {
			result -= 1;
		}
		System.out.println(result);
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int a = Integer.parseInt(tokens[0].substring(0, 3));
		int b = Integer.parseInt(tokens[1].substring(0, 3));
		int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0));
		int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0));
		int result = b - a + 1;
		if (A > min) {
			result -= 1;
		}
		if (B < max) {
			result -= 1;
		}
		System.out.println(result);
	}

} Main public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int a = Integer.parseInt(tokens[0].substring(0, 3));
		int b = Integer.parseInt(tokens[1].substring(0, 3));
		int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0));
		int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0));
		int result = b - a + 1;
		if (A > min) {
			result -= 1;
		}
		if (B < max) {
			result -= 1;
		}
		System.out.println(result);
	} main {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int a = Integer.parseInt(tokens[0].substring(0, 3));
		int b = Integer.parseInt(tokens[1].substring(0, 3));
		int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0));
		int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0));
		int result = b - a + 1;
		if (A > min) {
			result -= 1;
		}
		if (B < max) {
			result -= 1;
		}
		System.out.println(result);
	} Scanner in = new Scanner(System.in); in new Scanner(System.in) String[] tokens = in.nextLine().split(" "); tokens in.nextLine().split(" ") in.nextLine().split in.nextLine() in.nextLine in " " in.close() in.close in int A = Integer.parseInt(tokens[0]); A Integer.parseInt(tokens[0]) Integer.parseInt Integer tokens[0] tokens 0 int B = Integer.parseInt(tokens[1]); B Integer.parseInt(tokens[1]) Integer.parseInt Integer tokens[1] tokens 1 int a = Integer.parseInt(tokens[0].substring(0, 3)); a Integer.parseInt(tokens[0].substring(0, 3)) Integer.parseInt Integer tokens[0].substring(0, 3) tokens[0].substring tokens[0] tokens 0 0 3 int b = Integer.parseInt(tokens[1].substring(0, 3)); b Integer.parseInt(tokens[1].substring(0, 3)) Integer.parseInt Integer tokens[1].substring(0, 3) tokens[1].substring tokens[1] tokens 1 0 3 int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0)); min Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0)) Integer.parseInt Integer tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0) tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0) tokens[0].substring(0, 3) tokens[0].substring tokens[0] tokens 0 0 3 tokens[0].charAt(1) tokens[0].charAt tokens[0] tokens 0 1 tokens[0].charAt(0) tokens[0].charAt tokens[0] tokens 0 0 int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0)); max Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0)) Integer.parseInt Integer tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0) tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0) tokens[1].substring(0, 3) tokens[1].substring tokens[1] tokens 1 0 3 tokens[1].charAt(1) tokens[1].charAt tokens[1] tokens 1 1 tokens[1].charAt(0) tokens[1].charAt tokens[1] tokens 1 0 int result = b - a + 1; result b - a + 1 b - a b a 1 if (A > min) {
			result -= 1;
		} A > min A min {
			result -= 1;
		} result -= 1 result 1 if (B < max) {
			result -= 1;
		} B < max B max {
			result -= 1;
		} result -= 1 result 1 System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int a = Integer.parseInt(tokens[0].substring(0, 3));
		int b = Integer.parseInt(tokens[1].substring(0, 3));
		int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0));
		int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0));
		int result = b - a + 1;
		if (A > min) {
			result -= 1;
		}
		if (B < max) {
			result -= 1;
		}
		System.out.println(result);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int a = Integer.parseInt(tokens[0].substring(0, 3));
		int b = Integer.parseInt(tokens[1].substring(0, 3));
		int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0));
		int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0));
		int result = b - a + 1;
		if (A > min) {
			result -= 1;
		}
		if (B < max) {
			result -= 1;
		}
		System.out.println(result);
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		in.close();
		int A = Integer.parseInt(tokens[0]);
		int B = Integer.parseInt(tokens[1]);
		int a = Integer.parseInt(tokens[0].substring(0, 3));
		int b = Integer.parseInt(tokens[1].substring(0, 3));
		int min = Integer.parseInt(tokens[0].substring(0, 3) + tokens[0].charAt(1) + tokens[0].charAt(0));
		int max = Integer.parseInt(tokens[1].substring(0, 3) + tokens[1].charAt(1) + tokens[1].charAt(0));
		int result = b - a + 1;
		if (A > min) {
			result -= 1;
		}
		if (B < max) {
			result -= 1;
		}
		System.out.println(result);
	}

}
