//  [cpp]
/************************************************************************
*                  -> Bismillahir Rahmanir Rahim <-                     *
*                                                                       *
*                                                                       *
*                                                                       *
*                                                                       *
* __________             .___        .__              ____ ________     *
* \______   \_____     __| _/  ______|  |__  _____   /_   |\_____  \    *
*  |    |  _/\__  \   / __ |  /  ___/|  |  \ \__  \   |   | /  ____/    *
*  |    |   \ / __ \_/ /_/ |  \___ \ |   Y  \ / __ \_ |   |/       \    *
*  |______  /(____  /\____ | /____  >|___|  /(____  / |___|\_______ \   *
*         \/      \/      \/      \/      \/      \/               \/   *
*                                                                       *
*                                                                       *
*                                                                       *
*              .=.,                                                     *
*             ;c =\                                                     *
*           __|  _/                                                     *
*         .'-'-._/-'-._                                                 *
*        /..   ____    \                                                *
*       /' _  [<BF>] )  \                                               *
*      (  / \--\_>/-/'._ )                                              *
*       \-;_/\__;__/ _/ _/                                              *
*        '._}|==o==\{_\/                                                *
*         /  /-._.--\  \_                                               *
*        // /   /|   \ \ \                                              *
*       / | |   | \;  |  \ \                                            *
*      / /  | :/   \: \   \_\                                           *
*     /  |  /.'|   /: |    \ \                                          *
*     |  |  |--|   |--|     \_\                                         *
*     / _/   \ |   | /___--._) \                                        *
*    |_(---'-| >   | |       '-'                                        *
*           /_/     \_\                                                 *
*                                                                       *
 ***********************************************************************/
#include<bits/stdc++.h>

#define pi acos(-1)
typedef  long long ll;
typedef  unsigned long long ull;
typedef  unsigned un;
#define  vi  vector<int>
#define  vl  vector<ll>
#define  vd  vector<double>


//defined taking input;
#define sf           scanf
#define si(a)        sf("%d",&a)
#define sc(a)        sf("%c",&a)
#define sii(a,b)     sf("%d %d",&a,&b)
#define siii(a,b,c)  sf("%d %d %d",&a,&b,&c)
#define sl(a)        sf("%lld",&a)
#define sll(a,b)     sf("%lld %lld",&a,&b)
#define slll(a,b,c)  sf("%lld %lld %lld",&a,&b,&c)

#define pf           printf
#define pfi(a)       pf("%d\n",a)
#define pfii(a,b)    pf("%d %d\n",a,b)
#define pfl(a)       pf("%ld\n",a)
#define pfn          pf("\n")
#define pfyes        pf("YES\n")
#define pfno         pf("NO\n")
#define pfYes        pf("Yes\n")
#define pfNo         pf("No\n")
#define wh           while
#define wht(t)       while(t--)
#define endl         "\n"
#define pb           push_back

//defined using loop
#define For(i,a,n)   for(int i=a;i<=n;i++)

#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout);

using namespace std;

int main()
{
    int a,b;
    si(a);
    if(a>=1&&a<=9){
        b=a-0;
        cout<<b<<endl;
    }
    else if(a>=10&&a<=99){
        b = 9;
        cout<<b<<endl;
    }else if(a>=100&&a<=999){
        b = (a-100)+1+9;
        cout<<b<<endl;
    }else if(a>=1000&&a<=9999){
        b = (999-100)+1+9;
        cout<<b<<endl;
    }else if(a>=10000&&a<=99999){
        b=(999-100)+1+9+(a-1000)+1;
        cout<<b<<endl;
    }else if(a>=100000&&a<=999999){
        b = (999-100)+1+9+(99999-10000)+1;
        cout<<b<<endl;
    }



    return 0;
}