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

bool IsLeapYear(long long year)
{
    if(year % 400==0) return true;
    if(year%100!=0 && year%4==0) return true;
    return false;
}

void nextDay(long long &data)
{
    //分离年月日
    int year = data/10000;
    int mouth = data/100%100;
    int day = data%100;

    //下一天
    if(mouth==1||mouth==3||mouth==5||mouth==7||mouth==8||mouth==10||mouth==12)    //大月
    {
        day = day%31+1;
        if(day == 1) mouth++;
    }
    else if(mouth ==2)  //二月
    {
        //闰年
        if(IsLeapYear(year))
        {
            day = day%29+1;
            if(day == 1) mouth++;
        }
        else 
        {
        
            day = day%28+1;
            if(day == 1) mouth++;
        
        }
    }
    else {              //小月
        day = day%30+1;
        if(day == 1) mouth++;
    }

    //处理月
    if(mouth == 13) 
    {
        mouth = 1;
        year++;
    }

    data =  year*10000+mouth*100+day;
}

int main() {
    long long a,b;cin>>a>>b;
    int res=0;
    for(long long i=a;i<=b;nextDay(i))
    {
        string s1 = to_string(i);
        string s2 = s1;
        reverse(s1.begin(),s1.end());
        if(s1==s2) res++;
    }
    cout<<res;
}
// 64 位输出请用 printf("%lld")