package oj.test;
import java.util.Scanner;
/*
* 自守数
* 自守数是指一个数的平方的尾数等于该数自身的自然数。例如:252 = 625,762 = 5776,93762 = 87909376。请求
* 出n以内的自守数的个数
*
*/
public class Demo1 {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int num = sc.nextInt();
sop(count(num));
}
private static int count(int num) {
int count =0;
String sq = "";
for(int i=0;i<num;i++){
sq = i*i+"";
if(sq.endsWith(i+""))
count++;
}
return count;
}
private static void sop(Object obj) {
System.out.println(obj);
}
}