#include <iostream>
#include <cmath>
using namespace std;
bool square[100001];
int main(){
for(int i = 1; i <= 100000; ++i){
long double test = sqrt(i);
if( 0 == (test - (int) test) )
square[i] = true;
}
int a, b;
while(cin >> a >> b && a && b){
if(a > b)
swap(a, b);
int cnt = 0;
for(a ; a <= b; ++a)
if(square[a])
++cnt;
cout << cnt << endl;
}
return 0;
}