#include<bits/stdc++.h>
using namespace std;
int monthp[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int monthr[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int rn(int year){
if((year%4==0&&year%100!=0) || (year%400==0)) return 1;
return 0;
}
int hw(int date){
int t=0,d=date;
while(date!=0){
t=t*10+date%10;
date/=10;
}
if(t==d) return 1;
return 0;
}
int main(){
int begin,end,ans=0,year,month,day;
cin>>begin>>end;
if(begin==end&&hw(begin)) ans=1;
while(begin!=end){
year=begin/10000;
month=begin%10000/100;
day=begin%100;
if(hw(begin)) ans++;
day++;
if(rn(year)){
if(day>monthr[month]){
day=1;
month++;
}
}else{
if(day>monthp[month]){
day=1;
month++;
}
}
if(month>12){
month=1;
year++;
}
begin=year*10000+month*100+day;
}
cout<<ans;
return 0;
}