#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long l,r,num=0;
long long work(long long a)
{
int sum=0;
while(a>0)
{
sum+=(a%10);
a/=10;
}
return sum;
}
int main()
{
freopen("rabbits.in","r",stdin);
freopen("rabbits.out","w",stdout);
cin>>l>>r;
for(long long i=l;i<=r;i++)
{ long long ii=i*i;
if(work(i)*work(i)==work(i*i))
num++;
}
cout<<num;
return 0;
}