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

using ll = long long;

int main() {
    ll n; cin>>n;
    
    int ans = 0;
    for(ll i = 1; i <= 1000000; i++) {
        string s = to_string(i);
        string t = s + s;
        ll m = stoll(t);
        if(m<=n) {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


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

int main () {

string n, front, back;
cin >> n;

int len = n.length();

if (stoll(n) < 11) {
    cout << 0;
    return 0;
}

else if (len%2==1) {
    for (int i = 0; i < (len-1)/2;++i) {
        cout << '9';
    }
}
    else {
        for (int i = 0; i < len/2; ++i){
            front+=n[i];
        }
        for (int i = len/2; i < len; ++i){
            back+=n[i];
        }
        if (stoll(front) > stoll(back)) {
            cout << stoi(front)-1;
        }
        else {
            cout << front;
            
        }
    }
}
