#include <iostream>
using namespace std;
int main() {
int n;
while (cin >> n) {
int cnt = 0;
for (int i = 0; i <= n; ++i){
if (i % 10 == 0 || i % 10 == 1 || i % 10 == 5 || i % 10 == 6){
string str1 = to_string(i);
string str2 = to_string(i * i);
int pos = str2.size() - str1.size();
if (str2.find(str1, pos) != string::npos){
++cnt;
}
}
}
cout << cnt << endl;
}
return 0;
}

京公网安备 11010502036488号