#include<bits/stdc++.h>
using namespace std;
int main(){
int i,N,h,d=0;
	cin>>N; 
	for(i=1;i<=N;i++){
		h=i*i;
		if(h%10==i||h%100==i||h%1000==i||h%10000==i||h%100000==i||h%1000000==i){
			d++;
		}
	}
	cout<<d<<endl;
	return 0;
}
/**************************************************************
	Problem: 1729
	User: xiaojingxuan
	Language: C++
	Result: Accepted
	Time:31 ms
	Memory:2072 kb
****************************************************************/