import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextInt()) {
int cnt = 0;
int a = in.nextInt();
for(int i = 0; i<=a; i++){
double p = Math.pow(i,2);
String s = (int)p+"";
String s1 = i+"";
if(s1.equals(s.substring(s.length()-s1.length(),s.length()))){
cnt++;
}
}
System.out.print(cnt);
}
}
}