#include <bits/stdc++.h>

#define int long long
using namespace std;
const int mxN = 2e5 + 5;
const int INF = 1e18 + 7;

int N;

int stringtointeger(string x)
{
    int ans = 0, j = 1;

    for (int i = x.size() - 1; i >= 0; i--)
    {
        ans += (x[i] - '0') * j;
        j *= 10;
    }

    return ans;
}

string integertostring(int x)
{
    string ans = "";
    while (x > 0)
    {
        ans += (x % 10) + '0';
        x /= 10;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    freopen("Output.txt", "w", stdout);
    freopen("Error.txt", "w", stderr);
#endif

    cin >> N;
    if (N <= 10)
        cout << 0;
    else
    {
        int ans = 0;
        if (N >= 100000000000)
        {
            ans = 99999;
            int start = 100000;
            string s = integertostring(start);
            s += s;
            while (stringtointeger(s) <= N)
            {
                start++;
                ans++;
                s = integertostring(start);
                s += s;
            }
            cout << ans;
        } else if (N >= 1000000000)
        {
            ans = 9999;
            int start = 10000;
            string s = integertostring(start);
            s += s;
            while (stringtointeger(s) <= N)
            {
                start++;
                ans++;
                s = integertostring(start);
                s += s;
            }
            cout << ans;
        } else if (N >= 10000000)
        {
            ans = 999;
            int start = 1000;
            string s = integertostring(start);
            s += s;
            while (stringtointeger(s) <= N)
            {
                start++;
                ans++;
                s = integertostring(start);
                s += s;
            }
            cout << ans;
        } else if (N >= 100000)
        {
            ans = 99;
            int start = 100;
            string s = integertostring(start);
            s += s;
            while (stringtointeger(s) <= N)
            {
                start++;
                ans++;
                s = integertostring(start);
                s += s;
            }
            cout << ans;
        } else if (N >= 1000)
        {
            ans = 9;
            int start = 10;
            string s = integertostring(start);
            s += s;
            while (stringtointeger(s) <= N)
            {
                start++;
                ans++;
                s = integertostring(start);
                s += s;
            }
            cout << ans;
        } else if (N >= 10)
        {
            ans = 0;
            int start = 1;
            string s = integertostring(start);
            s += s;
            while (stringtointeger(s) <= N)
            {
                start++;
                ans++;
                s = integertostring(start);
                s += s;
            }
            cout << ans;
        }
    }

}

//20-03-2021  18:10:04
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    ll n; cin >> n;
    int ans = 0;
    for (int x = 1; ; x++) {
        if (stoll(to_string(x) + to_string(x)) > n) {
            cout << x - 1 << endl;
            return 0;
        }
    }
}