#include<bits/stdc++.h>
//#include <atcoder/all>

#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())
 
using namespace std;
//using namespace atcoder;
using ld = long double;
using ll = long long;
using P = pair<ll, ll>;
 
template<typename T> bool chmin(T& a, const T& b) { if(a > b){ a = b; return 1;} return 0; }
template<typename T> bool chmax(T& a, const T& b) { if(a < b){ a = b; return 1;} return 0; }

const ll ZER = 0;
const ll MOD = 998244353;
const ll INF = 1e18;


int main(){
    ll n;
    cin >> n;
    int res = 0;
    REP(i, 1, 1e6){
        ll tmp = i;
        int cnt = 0;
        while(tmp){
            cnt++;
            tmp /= 10;
        }
        ll now = (ll)i * powl(10, cnt)  + (ll)i;
        if(n < now)break;
        res++;
    }
    cout << res << endl;
}

#include <iostream>
#include <vector>
#include <deque>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <set>
#include <climits>
#include <string.h>
#include <unordered_map>
#include <queue>
#include <list>
#define int long long int
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const int mod = 1e9 + 7;

const int N = 1e6 + 5;

bool valid(string s)
{
	for(int i = 0; i < s.size(); i++)
	{
		if(i != s.size()-1 &&  s[i] == '.')
		{
			return true;
		}
	}
	return false;
}

int32_t main()
{

	fastio;
	int n;
	cin >> n;
	int low = 0;
	int high = 10000000;
	while(low + 1 < high)
	{
		int mid = low + (high - low) / 2;
		int d = log10(mid) + 1;
		int add = pow(10, d);
		int val = mid * add + mid;
		if(val <= n)
		{
			low = mid;
		}
		else
		{
			high = mid;
		}
		// cout << val << '\n';
	}
	cout << low << '\n';
	return 0;
}