#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    long long n, ans = 0;
    cin >> n;
    for(long long i = 1; i < n; i++){
        long long d = 1, j = i;
        while(j > 0){
            d *= 10;
            j /= 10;
        }
        long long x = i + d * i;
        if(x <= n) ans++;
        else break;
    }
    cout << ans << endl;
}

//code by: Ravi Khatri 
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define pb push_back
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define fr(i,n,s) for(int i=(int)n;i>=s;--i)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
#define mod 1000000007
ll pow(ll x,ll n){
	ll res=1LL;
	while(n){
		if(n%2){
			res=(res*x)%mod;
		}
		x=x%mod*x%mod;
		n>>=1;
	}
	return res;
}
void solve()
{
	ll n;cin>>n;
	for(int i=0;;++i){
		if(stoll(to_string(i)+to_string(i))> n){
			cout<<i-1<<"\n";
			return;
		}
	}
	
}
int main(){	Fast;
	// int t;cin>>t;
	// while(t--)
	solve();
}