#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF          = numeric_limits<long long>::max();
const long long DP_INF       = 1 << 29;
template <class T> using arr = vector<vector<T> >;
using vint                   = vector<int>;
using vll                    = vector<ll>;
// SourceTest用出力マクロ
#ifdef SOURCE_TEST
#define SPR(x) PR(x)
#define SPS(x) PS(x)
#define STRACE(var) cout << #var << "=" << var << endl;
#define SMAPTRACE(var)  \
    cout << #var << "=" \
         << "{" << var.first << "," << var.second << "}" << endl;
#else
#define SPR(x) \
    {}
#define SPS(x) \
    {}
#define STRACE(var) \
    {}
#define SMAPTRACE(var) \
    {}
#endif
int main() {
    ll N;
    cin >> N;

    ll left = 0;
    for (ll i = 10;; i *= 10) {
        if (N < (i * i)) break;
        left = i;
    }
    ll right = max(left * 10, (ll)10);
    ll mul   = right;
    left--;
    right++;

    auto funcIsOk = [&N, &mul](ll v) {
        ll value = v * mul + v;
        STRACE(value);
        return value <= N;
    };

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;
        STRACE(mid);
        if (funcIsOk(mid)) {
            SPR("OK");
            left = mid;
        } else {
            SPR("NG");
            right = mid;
        }
    }

    STRACE(left);
    STRACE(right);

    PR(left);
    return 0;
}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long double> vd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<ll,ll>> vp;

#define int ll
#define PB push_back
#define pb pop_back
#define in insert 
#define endl "\n"
#define MP make_pair
#define f first
#define PI 3.141592653589
#define nd second
#define Trav(a,x) for(auto &a: x)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
const int MOD  = 998244353;
const int maxn = 2e6+1;

int a,b,c,d,e,k,n,m,t,s,q,x,y,ans;

int32_t main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    ans = 0;
    for(int i = 1;i <= 999999 ; i++){
    	string s = to_string(i);
    	if(stoll(s+s) <= n)ans++;
	}
	cout<<ans;
    return 0;
}