#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

typedef long long ll;

ll pow (ll a, ll n) {
	if (n==0)
		return 1;
	if (n==1)
		return a;

	ll tmp = pow (a, n/2);
	ll tmp2 = tmp*tmp;
	if (n%2)
		return tmp2*a;
	return tmp2;
}

int main () {
	ll N;
	cin >> N;
	ll tmp = 1;
	ll keta = 0;
	for (int i=0; i<12; i++) {
		if (N / tmp > 0) {
			keta ++;
		}
		tmp *= 10;
	}
	ll ans = 0;
	tmp = 1;
	for (int i=3; i<=keta; i+=2) {
		ans += 9*tmp;
		tmp *= 10;
	}
	if (keta%2 == 0) {
		ll hketa = keta / 2;
		ll d = pow(10, hketa);
		ll Nh = N / d;
		ll Nl = N % d;
		ans += Nh - d/10;
		if (Nl >= Nh)
			ans ++;
	}
	cout << ans << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  string n;cin>>n;
  ll X = (ll)n.size();
  string S;
  ll Q = stoll(n);
  if(Q<10){
      cout<<0<<endl;
      return 0;
  }
  if(X%2==1){
      n="";
      for(ll i=0;i<X-1;i++){
          n+='9';
      }
  }
  ll Y = (ll)n.size();
  string B;
  string C;
  for(ll i=0;i<Y/2;i++){
      B+=n[i];
  }
  for(ll i=Y/2;i<Y;i++){
      C+=n[i];
  }
  //cout<<B<<endl;
  ll b = stoll(B);
  ll c = stoll(C);
  if(b>c){
      cout<<b-1<<endl;
  }else{
      cout<<b<<endl;
  }
}
