#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()


int get_smaller_half(ll n) {
    string s = to_string(n);
    int nsize = s.length();
    if (nsize % 2 == 1) {
        exit(9);
    }
    int M = nsize / 2;
    string lhss, rhss;
    for (int i = 0; i < s.size(); ++i) {
        if (i < M) {
            lhss += s.at(i);
        } else {
            rhss += s.at(i);
        }
    }
    int lhs = stoi(lhss), rhs = stoi(rhss);
    if (lhs > rhs) {
        return lhs - 1;
    } else {
        return lhs;
    }
}

void solve(long long N) {
    for (ll i = 1; i < 2e12; i++) {
        if (stoll(to_string(i) + to_string(i)) > N) {
            cout << i - 1 << endl;
            return;
        }
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
    ll n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i<pow(10, log10(n)); i++){
        string s = to_string(i);
        s += s;
        if(stol(s) > n){
            break;
        }
        else{
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}