#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int latte=1000000001;
int ans;
int t;
string T;
void dfs(int i,string &s){
    if(i>=(T.size()+1)/2){
        stringstream ss;ss<<s;int x;ss>>x;
        if(x<=t)ans++;
        return ;
    }
    for(int j=0;j<10;j++){
        if(i==0&&j==0)continue;
        s[i]='0'+j;
        s[T.size()-1-i]='0'+j;
        dfs(i+1,s);
    }
}
signed main(){
    int n;cin>>n;
    t=n/latte;
    if(t==0){
        cout<<0<<endl;
        return 0;
    }

    stringstream ss;ss<<t;ss>>T;
    for(int i=1;i<T.size();i++){
        int x=(i+1)/2;
        int y=9;
        for(int j=0;j<x-1;j++)y*=10;
        ans+=y;
    }

    string s(T.size(),'0');
    dfs(0,s);
    cout<<ans<<endl;
    return 0;
}