#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF 0x3f3f3f3f
#define endl "\n"
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef long long LL;
const int N = 1e5+3,MOD = 100000007;
int n;
int d1,d2;
int mon[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
bool ck(int d){//判断当前日期是否是合规日期
int x = d / 10000,y = d % 10000 / 100,z = d % 10000 % 100;//x:年,y:月,z:天
int leap = (x % 400 == 0 || (x % 4 == 0 && x % 100 != 0)) ? 1 : 0;//判断是否是闰年
if(y == 2 && z > mon[2] + leap) return false;//特判2月份
if(!y || y > 12 || (y != 2 && z > mon[y]) || !z) return false;//判断月和天数,不能为0,不能超限
return true;
}
void solve(){
while(cin >> d1 >> d2){
LL ret = 0;
for(int i = 1000;i < 10000;++i){//枚举所有年份,把月和日根据年份构造出来回文日期
int new_d = i,t = i;
for(int j = 0;j < 4;++j) new_d = new_d * 10 + t % 10,t /= 10;//构造回文日期
if(new_d >= d1 && new_d <= d2 && ck(new_d)) ++ret;//判断回文日期是否在范围内并且是否合法
}
cout << ret << endl;
}
}
int main(){
#ifdef LOCAL
freopen(".w/ac.in","r",stdin);
freopen(".w/ac.out","w",stdout);
#endif
IOS;
int TT = 1;
// cin >> TT;
while(TT--) solve();
return 0;
}