#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll N; cin >> N;
    N /= ll(1e9+1);
    ll ans = 0;
    for(ll y = 1; y < ll(1e5); y++) {
        string s = to_string(y);
        if(stoll(s + string(s.rbegin(), s.rend())) <= N) ans++;
        if(stoll(s + string(s.rbegin(), s.rend()).substr(1)) <= N) ans++;
    }
    cout << ans << endl;
}