import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int num = sc.nextInt();
            int count = 0;// 自守数的个数
            for(int i = 0 ; i <= num; i++){
                if((i * i +"").endsWith(i+"")){
                    count++;
                }
            }
            System.out.println(count);
        }
    }
}