#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int dayInMonth[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
bool isLeapYear(int year) {
    return (year % 100 != 0 && year % 4 == 0) || year % 400 == 0;
}
int getDayInMonth(int year, int month) {
    return (isLeapYear(year) && month == 2 ? 29 : dayInMonth[month]);
}
string i2s(int num, int w) {
    string s;
    while (num) {
        s += num % 10+'0';
        num /= 10;
    }
    while (s.length() < w) s +='0';
    reverse(s.begin(), s.end());
    return s;
}
bool isPa(string s) {
    string temp = s;
    reverse(s.begin(), s.end());
    return temp == s;
}
int main() {
    string a, b;
    cin >> a >> b;
    int cnt = 0;
    int year1 = stoi(a.substr(0, 4)), month1 = stoi(a.substr(4, 2)),
        day1 = stoi(a.substr(6, 2));
    int year2 = stoi(b.substr(0, 4)), month2 = stoi(b.substr(4, 2)),
        day2 = stoi(b.substr(6, 2));
    for (int i = year1; i <= year2; i++) {
        for (int j = (i == year1 ? month1 : 1); j <= (i == year2 ? month2 : 12); j++) {
            for (int z = (i == year1 && j == month1 ? day1 : 1); z <= (i == year2 &&
                    j == month2 ? day2 : getDayInMonth(i, j)); z++) {
                string target = i2s(i, 4) + i2s(j, 2) + i2s(z, 2);
                if (isPa(target)) cnt++;
            }
        }
    }
    cout << cnt;
}
// 64 位输出请用 printf("%lld")