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);
	}
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz