import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.valueOf(scan.nextLine().trim());
        int ans = 0;
        for (int i = 0; i <= n; i++) {
            if (isValid(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }
    public static boolean isValid(int num) {
        String str1 = num * num + "";
        String str2 = String.valueOf(num);
        return str1.substring(str1.length() - str2.length()).equals(str2);
    }
}