import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); while(in.hasNextInt()){ int n = in.nextInt(); System.out.println(CalcAutomorphicNumbers(n)); } } public static int CalcAutomorphicNumbers(int n){ // 求自守数的个数 int sum = 0; for(int i=0;i<=n;i++){ // 0和1都算 String s = String.valueOf(i); String S = String.valueOf(i*i); if(S.substring(S.length()-s.length()).equals(s)){ sum++; } } return sum; } }