#include<iostream>
#include<cstdio>
using namespace std;
long long cool(long long a);
long long l,t;
int main()
{
freopen("rabbits.in","r",stdin);
freopen("rabbits.out","w",stdout);
long long i,p,k,ans=0;
scanf("%lld%lld",&l,&t);
for(i=l;i<=t;i++)
if(cool(i)*cool(i)==cool(i*i))
{ans++;
//printf("%lld %lld\n",i,i*i);
// printf("%lld,",ans);
}
printf("%lld",ans);
return 0;
}
long long cool(long long a)
{
long long total=0;
while(a)
{
total+=a%10;
a=a/10;
}
return total;
}