#include <bits/stdc++.h>
using namespace std;

int main() {
  
  int64_t N;
  cin >> N;
  
  int d = to_string(N).length();
  
  int M = 1;
  for (int i = 0; i < d/2; i++) {
    M *= 10;
  }
  
  if (d%2 == 0) {
    if (N/M <= N%M) cout << N/M << endl;
    else  cout << N/M - 1 << endl;
  }
  else {
    cout << M - 1 << endl;
  }

return 0;
}
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxN = 1e6 + 5;
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	ll n;
	cin >> n;

	auto get_num = [] (string s) -> ll {
		ll res = 0;
		for(char &c : s) {
			res *= 10;
			res += (c - '0');
		}
		return res;
	};

	int ans = 0;
	for(int i = 1; i < maxN; i++) {
		string s = to_string(i);
		s += s;
		if(get_num(s) > n) continue;
		++ans;
	}
	cout << ans;
}