#include<iostream>
using namespace std;
string int_tostr(int d)
{
string res;
int s=d/10;
int y=d%10;
char ch=y+'0';
res.push_back(ch);
while(s)
{
y=s%10;
s/=10;
ch=y+'0';
res.push_back(ch);
}
return res;
}
bool cmpstr(string src,string dst)
{
int i=0;
int j=0;
while(src[i]!='\0'&&dst[j]!='\0')
{
if(src[i]!=dst[j])
{
return false;
}
i++;
j++;
}
return true;
}
int main()
{
int d;
while(cin>>d)
{
int count=0;
for(int i=0;i<=d;i++)
{
int v=i*i;
string stri=int_tostr(i);
string strv=int_tostr(v);
if(cmpstr(stri,strv))
{
//cout<<stri<<" "<<strv<<endl;
count++;
}
}
cout<<count<<endl;
}
return 0;
}