#include<stdio.h>

int judge(int n){

int ans = 0;
for(int i=0; i<=n; i++){
    int all = i*i;
    int x = i;
    int sign = 1;
    while(x!=0){
        if(x%10 != all%10){
            sign = 0;
            break;
        }
        x/=10;
        all/=10;
    }
    if(sign)ans++;
}
return ans;

}

int main(){

int number;
while(scanf("%d", &number) != EOF){
    int ans=judge(number);
    printf("%d\n", ans);
}

}