#include #define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++) #define REP(i,n) FOR(i,0,n) #define MOD 1000000007 #define int long long using namespace std; typedef long long ll; const int INF = 1e9; signed main() { ll N, M, cnt = 0; cin >> N; M = N / 1000000001; for (int i=1; i<100000; i++) { string V = to_string(i); string S = V, T = V; reverse(V.begin(), V.end()); S += V; T += V.substr(1, V.size()-1); if (stoll(S) <= M) cnt++; if (stoll(T) <= M) cnt++; } cout << cnt << endl; }