#include <cstdio> #include <cstring> char arr1[128], arr2[128]; bool isZs(int n) { if(n < 5) { return n < 2; } int g = n % 10; if(g == 0 || g == 1 || g == 5 || g == 6) { sprintf(arr1, "%d", n); sprintf(arr2, "%d", n * n); int len1 = strlen(arr1), len2 = strlen(arr2); for(int i = 0; i<len1; i++) { if(arr1[i] != arr2[len2-len1+i]) { return false; } } return true; } else { return false; } } int main() { int n; while(EOF != scanf("%d", &n)) { int cnt = 0; for(int i=0; i<=n; i++) { if(isZs(i)) { cnt++; } } printf("%d\n", cnt); } return 0; }