#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;

int main(){
  ull n,c=0;
  cin >> n;
  for(ull i=1;i<1000000;i++){
    string s = to_string(i) + to_string(i);
    if(stoull(s)<=n){
      c++;
    }
    else{
      break;
    }
  }
  cout << c << endl;
  return 0;
}
/*
 * @Author: Luisvacson
 * @LastEditors: Luisvacson
 * @Descriptions: None
 * @Date: 2021-03-20 20:06:05
 * @LastEditTime: 2021-03-20 20:40:54
 * @FilePath: \C++\Practice\ABC196C.cpp
 */
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[15], b[15];
string s;

signed main() {
    cin >> s;
    int n = s.size(), m, t = 1, ans = 0;
    if (n & 1)
        m = n >> 1;
    else
        m = (n >> 1) - 1;

    for (int i = 1; i <= m; i++) {
        ans += t * 9;
        t *= 10;
    }

    if (!(n & 1)) {
        ans = 0;
        int x = n / 2, cnt = 1;
        for (int i = 0; i < x; i++) a[i] = (s[i] - '0');
        for (int i = x; i < n; i++) b[i - x] = (s[i] - '0');
        bool flag = false;
        for (int i = 0; i < x; i++) {
            if (a[i] > b[i]) {
                flag = true;
                break;
            } else if (a[i] < b[i])
                break;
        }
        for (int i = 1; i < x; i++) {
            cnt *= 10;
        }
        for (int i = 0; i < x; i++) {
            ans += a[i] * cnt;
            cnt /= 10;
        }
        if (flag) ans--;
    }
    cout << ans << endl;
    return 0;
}