import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		int au = a / 1000;
		int aur = au % 10 * 10 + au / 10;
		int am = a / 100 % 10;
		int al = a % 100;
		if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		}

		int bu = b / 1000;
		int bur = bu % 10 * 10 + bu / 10;
		int bm = b / 100 % 10;
		int bl = b % 100;
		if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		}

		int num = (bu - au - 1) * 10 + 11 - am + bm;

		System.out.println(num);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		int au = a / 1000;
		int aur = au % 10 * 10 + au / 10;
		int am = a / 100 % 10;
		int al = a % 100;
		if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		}

		int bu = b / 1000;
		int bur = bu % 10 * 10 + bu / 10;
		int bm = b / 100 % 10;
		int bl = b % 100;
		if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		}

		int num = (bu - au - 1) * 10 + 11 - am + bm;

		System.out.println(num);
	}
} Main public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		int au = a / 1000;
		int aur = au % 10 * 10 + au / 10;
		int am = a / 100 % 10;
		int al = a % 100;
		if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		}

		int bu = b / 1000;
		int bur = bu % 10 * 10 + bu / 10;
		int bm = b / 100 % 10;
		int bl = b % 100;
		if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		}

		int num = (bu - au - 1) * 10 + 11 - am + bm;

		System.out.println(num);
	} main {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		int au = a / 1000;
		int aur = au % 10 * 10 + au / 10;
		int am = a / 100 % 10;
		int al = a % 100;
		if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		}

		int bu = b / 1000;
		int bur = bu % 10 * 10 + bu / 10;
		int bm = b / 100 % 10;
		int bl = b % 100;
		if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		}

		int num = (bu - au - 1) * 10 + 11 - am + bm;

		System.out.println(num);
	} @SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in); stdin new Scanner(System.in) int a = stdin.nextInt(); a stdin.nextInt() stdin.nextInt stdin int b = stdin.nextInt(); b stdin.nextInt() stdin.nextInt stdin int au = a / 1000; au a / 1000 a 1000 int aur = au % 10 * 10 + au / 10; aur au % 10 * 10 + au / 10 au % 10 * 10 au % 10 au 10 10 au / 10 au 10 int am = a / 100 % 10; am a / 100 % 10 a / 100 a 100 10 int al = a % 100; al a % 100 a 100 if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		} aur < al aur al {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		} am++ am if (am == 10) {
				am = 0;
				au++;
			} am == 10 am 10 {
				am = 0;
				au++;
			} am = 0 am 0 au++ au int bu = b / 1000; bu b / 1000 b 1000 int bur = bu % 10 * 10 + bu / 10; bur bu % 10 * 10 + bu / 10 bu % 10 * 10 bu % 10 bu 10 10 bu / 10 bu 10 int bm = b / 100 % 10; bm b / 100 % 10 b / 100 b 100 10 int bl = b % 100; bl b % 100 b 100 if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		} bur > bl bur bl {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		} bm-- bm if (bm == -1) {
				bm = 9;
				bu--;
			} bm == -1 bm -1 1 {
				bm = 9;
				bu--;
			} bm = 9 bm 9 bu-- bu int num = (bu - au - 1) * 10 + 11 - am + bm; num (bu - au - 1) * 10 + 11 - am + bm (bu - au - 1) * 10 + 11 - am (bu - au - 1) * 10 + 11 (bu - au - 1) * 10 (bu - au - 1) bu - au - 1 bu au 1 10 11 am bm System.out.println(num) System.out.println System.out System System.out num String[] args args public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		int au = a / 1000;
		int aur = au % 10 * 10 + au / 10;
		int am = a / 100 % 10;
		int al = a % 100;
		if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		}

		int bu = b / 1000;
		int bur = bu % 10 * 10 + bu / 10;
		int bm = b / 100 % 10;
		int bl = b % 100;
		if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		}

		int num = (bu - au - 1) * 10 + 11 - am + bm;

		System.out.println(num);
	}
} public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		int au = a / 1000;
		int aur = au % 10 * 10 + au / 10;
		int am = a / 100 % 10;
		int al = a % 100;
		if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		}

		int bu = b / 1000;
		int bur = bu % 10 * 10 + bu / 10;
		int bm = b / 100 % 10;
		int bl = b % 100;
		if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		}

		int num = (bu - au - 1) * 10 + 11 - am + bm;

		System.out.println(num);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int a = stdin.nextInt();
		int b = stdin.nextInt();

		int au = a / 1000;
		int aur = au % 10 * 10 + au / 10;
		int am = a / 100 % 10;
		int al = a % 100;
		if (aur < al) {
			am++;
			if (am == 10) {
				am = 0;
				au++;
			}
		}

		int bu = b / 1000;
		int bur = bu % 10 * 10 + bu / 10;
		int bm = b / 100 % 10;
		int bl = b % 100;
		if (bur > bl) {
			bm--;
			if (bm == -1) {
				bm = 9;
				bu--;
			}
		}

		int num = (bu - au - 1) * 10 + 11 - am + bm;

		System.out.println(num);
	}
}
