import java.io.*; import java.util.*; public class Main { /************************* 功能: 求出n以内的自守数的个数 输入参数: int n 返回值: n以内自守数的数量。 */ public static int CalcAutomorphicNumbers(int n) { int count = 0, base = 1; for (int i = 0; i <= n; i++) { if (i >= base) { base *= 10; } if (i * i % base == i) { count++; } } return count; } public static void main (String [] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); String line = null; while ((line = f.readLine()) != null) { int n = Integer.parseInt(line); int res = CalcAutomorphicNumbers(n); out.println(res); } out.close(); f.close(); } }