#include <bits/stdc++.h>
bool runnian(int date){
int year = date/10000;
if((year%4==0&&year%100!=0)||(year%400==0)){
return true;
}else return false;
}
bool huiwenshu(int date){
int temp = date,ans=0;
while(temp>0){
ans = ans*10+temp%10;
temp/=10;
}
if(ans==date) return true;
else return false;
}
bool riqi(int date){
int year = date/10000;
int month = (date/100)%100;
int day = date%100;
bool b_month = false;
bool b_day = false;
if(month>=1&&month<=12) b_month = true;
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:{
if(day==31) b_day = true;
break;
}
case 4:
case 6:
case 9:
case 11:{
if(day==30) b_day = true;
break;
}
case 2:{
if(runnian(year)){
if(day==29) b_day = true;
}else{
if(day==28) b_day = true;
}
break;
}
}
if(b_month&&b_day) return true;
else return false;
}
using namespace std;
int main()
{
int date1,date2,sum=0;
cin>>date1>>date2;
for(int i=date1;i<=date2;i++){
if(riqi(i)&&huiwenshu(i)) sum++;
}
cout<<sum<<endl;
return 0;
}