import java.util.Scanner;

/**
 * HJ99 自守数
 */
public class HJ099 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int count = 0;
            for (int i = 0; i <= n; i++) {
                int m = i * i;
                String s = Integer.toString(m);
                String t = Integer.toString(i);
                if (s.endsWith(t)) {
                    count++;
                }
            }
            System.out.println(count);
        }
        sc.close();
    }

}