#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; const int M = 1000000001; ll N; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> N; ll m = N / M; // m以下の整数のうち回文となるもの ll ans = 0; // 偶数長 for(ll i = 1; ; ++i) { string s = to_string(i), t = s; reverse(all(t)); ll x = stoll(s + t); if(x > m)break; ans++; } // 奇数長 for(ll i = 0; i <= 9; ++i) { if(i!=0 && i <= m)++ans; for(ll j = 1;; ++j) { string s = to_string(j), t = s; reverse(all(t)); ll x = stoll(s + to_string(i) + t); if(x > m)break; ans++; } } cout << ans << endl; }