import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int count = 0;
            for (int i = 0; i <= n; i++) {
                long square = (long) Math.pow(i, 2);
                String squareStr = String.valueOf(square);
                String s = String.valueOf(i);
                if (squareStr.indexOf(s) == (squareStr.length() - s.length())) {
                    count++;
                }

            }
            System.out.println(count);
        }
        sc.close();
    }
}