
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

//insert,find_by_order,order_of_key,lower_bound,upper_bound;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

  
//////////////////////////////code//////////////////////////////

const int N = 200;



void solve()
{

		int n;
		cin >> n;

		int temp = n;
		int cnt = 0;

		vi s;

		while(temp)
			cnt++,s.pb(temp%10),temp/=10;

		int ans  = 0;

		for(int i = 2;i < cnt; i += 2)
		{
				int curr = 9;

				for(int j = 1;j < i/2; j++)
					curr*=10; 

				ans += curr;

		}

		

		if(cnt&1)
		{
				db(ans)
				return;
		}

		reverse(all(s));

		
		for(int i = 0;i < (cnt/2); i++)
		{
				int curr = 0;
                 
                if(i == 0)
				curr = max(s[i] - 1,0ll);
			    else
			    curr = s[i];


				for(int j = i + 1;j < (cnt/2) ;j++)
					curr*=10;

				ans += curr;
		}
         
        int f = 1;

		for(int i = 0;i < cnt/2 ;i++)
		{
				if(s[i] > s[cnt/2 + i])
					f = 0;
				else if(s[i] < s[cnt/2 + i])
					break;
		}


		db(ans + f)


	

}

int32_t main()
{   

    LETS_GET_SCHWIFTY;

     #ifndef ONLINE_JUDGE
     freopen("INP.txt", "r", stdin);
     freopen("out.txt", "w", stdout);
     #endif  


    int t = 1;
  // cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


// KEEP CALM and Enjoy the Problem B-)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007 // 1e9+7
#define inf 1e18

#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
#define watch2(x,y) cout<<(#x)<<" is "<<(x)<<" and "<<(#y)<< " is " <<(y)<<"\n"

struct custom_hash {
    static uint64_t splitmix64(uint64_t x){
            // http://xorshift.di.unimi.it/splitmix64.c
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
    }
    
    size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
    }
};

ll integer_power(ll x, ll y){
// integer_func() funcs in O(log y) time. Just WOW!    
/* Take Care:
 MUST Remove modulo, if in Problem, dealing with integers >= 10^9*/

    ll res = 1;     // res -> result
  
    if (x == 0) 
        return 0;
  
    while (y > 0){    
        if (y & 1)  
            res = (res*x);

        y = y>>1; // y = y/2  
        x = (x*x);
    }  
    return res;  
}


ll count_no_of_digit(ll N){

    ll count;

    count = 0;
    while(N > 0){
        count += 1;
        N /= 10;
    }

    return count;
}

void run_case(){
    
    ll N,n,count_digit,i,ans,left,right;
    ll current_num;

    cin>>N;

    count_digit = count_no_of_digit(N);    
    //watch(count_digit);

    ans = 0;

    n = 2;
    while(n < count_digit){
        ans += 9 * integer_power(10,(n/2 - 1));
        n += 2;
    }

    if(n == count_digit){
        // n is even

        left = N / (integer_power(10,n/2));
        right = N % (integer_power(10,n/2));

        i = integer_power(10,(n/2-1));
        while(1){

            current_num = i*integer_power(10,n/2) + i;
            //watch(current_num);

            if(current_num > N)
                break;

            ans += 1;
            i += 1;
        }
    }

    cout<<ans<<"\n";

}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll T = 1;
    //cin>>T;
    while(T--)
        run_case();

    return 0;
}