import java.util.Scanner;

public class Main {

public static void main(String[] args) {    

    Scanner scanner = new Scanner(System.in);
    int num = scanner.nextInt();
    int count = 0;
    for (int i = 0; i <= num; i++) {
        String a = String.valueOf(i * i);
        if (a.endsWith(String.valueOf(i))) {
            count++;
        }
    }
    System.out.println(count);
}

}