#include <bits/stdc++.h> using namespace std; bool isZiShouShu(int num){ int tmp = num * num; string s1 = to_string(num); string s2 = to_string(tmp); reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end()); //cout << s1 << "," << s2 << endl; int i = 0; while(i < s1.size()){ if(s1[i] != s2[i]){ return false; } i++; } return true; } int main(){ int n = 0; while(cin >> n){ int res = 0; for(int i = 0; i <= n; i++){ if(isZiShouShu(i)) res++; } cout << res << endl; } return 0; }