#include <bits/stdc++.h>

using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  long long int i=1;
  long long int ans=0;
  bool flag=false;
  long long int N;
  cin >> N;
  while(flag==false){
    string str1 = to_string(i);
    string str2 = to_string(i);
    string str = str1+str2;
    long long int num = (long long int)stol(str);
    if(num<=N){
      ans++;
      i++;
    }else{
      flag = true;
    }
  }
  cout << ans;
  
}
#include<bits/stdc++.h>
using namespace std;


#define int             long long
#define pb              push_back
#define ppb             pop_back
#define pf              push_front
#define ppf             pop_front
#define all(x)          (x).begin(), (x).end()
#define uniq(v)         (v).erase(unique(all(v)), (v).end())
#define sz(x)           (int)((x).size())
#define ff              first
#define ss              second
#define rep(i, a, b)    for(int i = a; i <= b; i++)
#define mem1(a)         memset(a, -1, sizeof(a))
#define mem0(a)         memset(a, 0, sizeof(a))
#define endl            "\n"
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;


const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;









int binpow(int a, int b) {
	int res = 1;
	while (b > 0) {
		if (b & 1) {
			res = a * res;
		}
		a = a * a;
		b >>= 1;
	}
	return res;
}




void fast_io()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

vi num;

void precompute() {

	for (int i = 1; i <= 6; i++) {
		int low = binpow(10, i - 1);
		int high = binpow(10, i) - 1;
		for (int j = low; j <= high; j++) {
			int tmp = j * binpow(10, i) + j;
			num.pb(tmp);
		}
	}
}

void solve() {
	int n; cin >> n;



	auto it = upper_bound(all(num), n);

	int ind = it - num.begin();

	cout << ind << endl;









}

signed main()
{
	fast_io();
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;

	// cin >> t;
	precompute();


	while (t--) {

		solve();


	}
	return 0;


}