#include <iostream>
#include<string>
using namespace std;

const int monthr[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monthp[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};


bool pd(string ss) {
    for (int i = 0; i < 4; i++) {
        if (ss[i] != ss[7 - i]) {
            return false;
        }
    }
    return true;
}
bool is_r(int ss) {
    int year = ss / 10000;
    if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
        return true;
    }
    return false;
}
//20110101

void solve() {
    int a, b;
    cin >> a >> b;
    int sum = 0;
    string tmp = to_string(a);
    if (pd(tmp)) {
        sum++;
    }
    while (a < b) {
        a++;
        int d = a % 100, m = (a / 100) % 100, y = a / 10000;
        if (is_r(a)) {
            if (d > monthr[m]) {
                d = 1;
                m++;
                if (m > 12) {
                    m = 1;
                    y++;
                }
            }
        } else {
            if (d > monthp[m]) {
                d = 1;
                m++;
                if (m > 12) {
                    m = 1;
                    y++;
                }
            }
        }
        a = y * 10000 + m * 100 + d;
        tmp = to_string(a);
        if (pd(tmp)) {
            sum++;
        }
    }
    cout << sum << endl;
}

int main() {
    solve();
}
// 64 位输出请用 printf("%lld")