#include <iostream>
using namespace std;
#include <vector>
#include <set>
#include<string>
#include <algorithm>
#include <cmath>
#include <climits>
typedef long long ll;
typedef unsigned long long ull;


//AtCoder Begginer Contest 196 D
int main(void) 
{
	ll n;
	cin >> n;

	ll ans;

	for (ll i = 0; i < 10000000; i++)
	{
		// ll(整数) -> string(文字列)
		string strTmp=to_string(i);

		strTmp = strTmp + strTmp;

		ll tmpll = stoll(strTmp);
		
		if (tmpll > n)
		{
			ans = i - 1;
			break;
		}

	}

	cout << ans;

	return 0;
}
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    long long N;
    cin >> N;
    int ans = 0;
    for (long long i = 1, pwr = 10; ; i++) {
        if (i%pwr == 0) pwr *= 10;
        if (i + pwr*i > N) break;
        ans++;
    }
    cout << ans << '\n';
    return 0;
}