// 活动地址: 牛客春招刷题训练营 - 编程打卡活动
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define int long long 

using namespace std;


bool check(int x){
    int len=0,t=x;// 记录x的位数 
    string t1=to_string(x);// 将两个转化为 字符串比较 
    while(t){
        len++;
        t/=10;
    }
    string  t2=to_string(x*x); // 其平方数
    if(t2.substr(t2.size()-t1.size())==t1)return 1; // 如果满足条件 返回 1
    else return 0; 

}

void solve(){
  int n,ans=0;
  cin>>n;
  for(int i=0;i<=n;i++){
    if(check(i)){
        ans++;
      //  cout<<i<<" \n";
    }
  }
  cout<<ans;
}

signed main(){
    int T=1;
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
   // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}
// 活动地址: 牛客春招刷题训练营 - 编程打卡活动