#include <iostream>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)

int main()
{
    long long N;
    cin >> N;
    long long digit = (long long)(log10(N)) + 2;
    long long upper = 1;
    REP(i, digit / 2){
        upper *= 10;
    }

    long long ans = 0;
    FOR(i, 1, upper + 1){
        string val = to_string(i) + to_string(i);
        if(stoll(val) <= N){
            ans++;
        }
    }

    cout << ans << endl;
}

//I still luve you Kashish <3
#include<bits/stdc++.h>
using namespace std ;
#define int                             long long
#define pb                              push_back
#define F                               first
#define S                               second
#define P                               push
#define nl                              "\n"
#define vvi                             vector<vector<int>>
#define vi                              vector<int>
#define vc                              vector<char>
#define pii                             vector<pair<int, int>>
#define sz(a)                           (int)a.size()
#define all(a)                          a.begin(),a.end()
#define sort(v)                         sort(all(v))
#define sortr(v)                        sort(v); reverse(all(v));
#define yes                             cout << "YES"
#define no                              cout << "NO"
#define PeeleMera                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
int binpow(int a, int b)                { int res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;}
int binpowmod(int a, int b, int mod)    { int res = 1; while (b > 0) { if (b & 1) res = res * a , res = res % mod ; a = a * a , a = a % mod ; b >>= 1 ; } return res % mod; }
const int                               N = 1e9 + 7 , N1 = 1e7 + 5 , N2 = 1e6 + 3, N3 = 1e5 + 3;
#define IM                              -1e18
#define IX                              1e18

void solve()
{
	int n;
	cin>>n;
	string s=to_string(n);
	int cnt=0, f=0;
	if(n<10)
	{
		cout<<0;
		return;
	}
	if(sz(s)%2)
	{
		n=0;
		for(int i=0;i<sz(s)-1;i++)
		{
			n+=9*pow(10, i);
		}
	}
	for(int i=1;i<sz(s);i++)
	if(s[i]=='0')
	cnt++;
	if(cnt==sz(s)-1)
	n--,f=1;

	cnt=0;
	s=to_string(n);
	int m=sz(s), ff=0;
	for(int i=0;i<m/2;i++)
	{
		if(s[i]<s[i+m/2])
		ff=1;
		if(s[i]<=s[i+m/2])
		cnt++;
		else if(ff>0)
		cnt++;
		else break;
	}
	if(cnt==m/2 or f==1)
	for(int i=0;i<sz(s)/2;i++)
	cout<<s[i];
	else 
	{
		int n=0;
		// cout<<" Yaha ";
		for(int i=0;i<m/2;i++)
		n+=(s[i]-48)*pow(10,m/2-i-1);
		n--;
		cout<<n;
	}
}

signed main()
{
    PeeleMera;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    // cout<<fixed<<setprecision(9);
    while(t--)
    {
        solve();
        cout<<endl;
    }
}


    