#include<bits/stdc++.h>
using namespace std;
#include <iostream>
#include <sstream>
#define ll long long

int main()
{
    ll i,j,k,n,m,a,b;
    string st;

    cin>>st;
    n=st.size();
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    string st1="",st2="";
    if(n%2==1){
        for(i=0;i<n/2;i++){
            cout<<'9';
        }
    }
    else{
        for(i=0;i<n/2;i++){
            st1+=st[i];
        }
        for(i=n/2;i<n;i++){
            st2+=st[i];
        }

        //stringstream sstr(st1);
        //stringstream sstr(st2);
        ll x=stoll(st1);
        ll y=stoll(st2);

        if(x<=y){
            cout<<x<<endl;
        }
        else{
                x--;
            cout<<x<<endl;
        }

    }

}

#include <cstdio>
#include <cmath>
using namespace std;

typedef long long LL;

inline bool check(const LL& x, const LL& n)
{
	LL p = 1LL;
	while(p <= x) p *= 10LL;
	return x * p + x <= n;
}

int main()
{
	LL n;
	scanf("%lld", &n);
	LL l = 0LL, r = sqrt(n);
	while(l < r)
	{
		LL mid = l + r + 1LL >> 1LL;
		if(check(mid, n)) l = mid;
		else r = mid - 1;
	}
	printf("%lld\n", l);
	return 0;
}