import java.util.Scanner;
public class Main {
/*
题目描述
自守数是指一个数的平方的尾数等于该数自身的自然数。例如:25^2 = 625,76^2 = 5776,9376^2 = 87909376。请求出n以内的自守数的个数
输入描述:
int型整数
输出描述:
n以内自守数的数量。
输入例子:
2000
输出例子:
8
*/
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
while(scn.hasNext()){
System.out.println(totalZiShouShu(scn.nextInt()));
}
}
public static int totalZiShouShu(int n){
int count=0;
for (int i = 0; i <= n; i++) {
String str=i+"";
if((i*i-i)%(int)Math.pow(10, str.length())==0){
//System.out.println(i);
count++;
}
}
return count;
}
}