#include<bits/stdc++.h>
using namespace std;
bool isRun(int year) {
    if ((year % 4 == 0 && year / 100 != 0) || year / 400 == 0) {
        return true;
    }
    return false;
}
int monday(int year, int mon) {
    switch (mon) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            return 31;
        case 4:
        case 6:
        case 9:
        case 11:
            return 30;
        case 2:
            return (isRun(year) == true ? 29 : 28);
        default:
            return 0;
    }
}
bool isHuiwen(int x) {
    string s = to_string(x);
    for (int i = 0; i < 8; i++) {
        if (s[i] != s[7 - i])return false;
    }
    return true;
}
int getJinwei(int a, int b, int c) {
    if (c > monday(a, b))c = 1, b++;
    if (b > 12)b = 1, a++;
    return a * 10000 + b * 100 + c;
}
int main() {
    int st, en, ans = 0;
    cin >> st >> en;
    int cur = st;

    while (cur <= en) {
        int a = cur / 10000;
        int b = cur / 100 % 100;
        int c = cur % 100;
        if (isHuiwen(cur))ans++;
        cur = getJinwei(a, b, c + 1);
    }
    cout << ans << endl;
    return 0;
}