import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
int a = sc.nextInt();
String str1 = Integer.toString(a);
if (a == 1) {
System.out.println(2);
} else {
int c = 0;
for (int i = 1; i <= a ; i++) {
double b = Math.pow(i, 2);
String str = Integer.toString((int)b);
String str4 = Integer.toString(i);
String str2 = new StringBuilder(str).reverse().toString();
String str3 = new StringBuilder(str4).reverse().toString();
if (str3.equals(str2.substring(0, str4.length()))) {
c++;
// System.out.println(str4+" "+str2);
}
}
System.out.println(c + 1);
}
}
}
}