import java.util.Scanner;

public class Main {
    // 回文判断:对称比较每一位
    static boolean isPalindrome(int a) {
        String s = Integer.toString(a);
        for (int i = 0; i < s.length() / 2; i++) {
            if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
                return false;
            }
        }
        return true;
    }

    // 判断闰年
    static boolean isLeapYear(int year) {
        return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
    }

    // 获取某月份的最大天数
    static int getMaxDay(int year, int month) {
        switch (month) {
            case 4:
            case 6:
            case 9:
            case 11:
                return 30;
            case 2:
                return isLeapYear(year) ? 29 : 28;
            default: // 1,3,5,7,8,10,12
                return 31;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int count = 0;

        // 直接遍历区间内所有日期,逐天判断
        for (int date = a; date <= b; date++) {
            // 拆分年月日
            int year = date / 10000;
            int month = (date / 100) % 100;
            int day = date % 100;

            // 先判断日期是否合法
            boolean valid = (month >= 1 && month <= 12) && (day >= 1 && day <= getMaxDay(year, month));

            // 合法且是回文则计数
            if (valid && isPalindrome(date)) {
                count++;
            }
        }
        System.out.println(count);
        sc.close();
    }
}