w135 @ 2024-10-22 16:48:02
#include<bits/stdc++.h>
using namespace std;
long long a,b,sum;
long long days[] = {-1ll, 31ll, 28ll, 31ll, 30ll, 31ll, 30ll, 31ll, 31ll, 30ll, 31ll, 30ll, 31ll};
long long make_hw(string s){//前4位生成全8位
for(long long i=3ll;i>=0ll;i--){
s+=s[i];
}
return atoll(s.c_str());
}
bool is_tov(long long y,long long m,long long d){
if (!m || m > 12ll) return false;
if (!d) return false;
if (m != 2ll)
{
if (d > days[m]) return false;
}
else
{
bool leap = (y % 400ll == 0ll) || (y % 4ll == 0ll && y % 100ll != 0ll);
if (d > 28 + (leap? 1ll:0ll)) return false;
}
return 1;
}
int main() {
cin>>a>>b;
if(make_hw(to_string(a/10000ll))>a)sum++;
for(int i=a/10000ll+1ll;i<=b/10000ll-1ll;i++){
long long the_hw=make_hw(to_string(i));
if(is_tov(the_hw/10000ll,the_hw%10000ll/100ll,the_hw%100ll)){
sum++;
}
}
if((make_hw(to_string(b/10000))<b)&&(a/10000ll!=b/10000ll))sum++;
cout<<sum<<'\n';
return 0;
}