#include <cstdio>
int l,r,year,month,day;
bool judge(int n){
year=n/10000;
month=n%10000/100;
day=n%100;
if(n<l||n>r)return false;
if(day>=32||month>=13)return false;
if(day==31&&(month==2||month==4||month==6||month==9||month==11))return false;
if(day==30&&month==2)return false;
if(day==29&&month==2)
if(year%400==0||year%4==0&&year%100!=0)return true;
else return false;
return true;
}
using namespace std;
int main(){
int ly,ry,tot=0;
scanf("%d%d",&l,&r);
ly=l/10000;
ry=r/10000;
for(int i=ly;i<=ry;i++){
if(judge(i*10000+i%10*1000+i%100/10*100+i%1000/100*10+i/1000)==1)
tot++;
}
printf("%d",tot);
return 0;
}