#include <iostream>
 
using namespace std;
 
int main()
{
    long long n,count=0,ans=0;
    cin>>n;
    for(long long i=1000;i<=n;i = i*1000)
    {
        ans = ans + (n-i);
        count++;
    }
    cout<<ans+count;
 
    return 0;
}
#pragma GCC optimize("Ofast")
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <cctype>
#include <sstream>
#include <stack>
#include <deque>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>  

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Po = pair<double, double>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=ll(a);i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define PB push_back
#define MP make_pair
#define SZ(x) ll(x.size())
#define ALL(x) x.begin(),x.end()
#define NIL -1
#define INF 1ll<<63-1
//#define MOD 1000000007
#define PI 3.14159265358979323846
#define endl "\n"
#define EPS 1e-9
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl

template <class T, class U>
bool chmin(T& t, const U& u) {
	if (t > u) {
		t = u;
		return true;
	}
	else return false;
}
template <class T, class U>
bool chmax(T& t, const U& u) {
	if (t < u) {
		t = u;
		return true;
	}
	else return false;
}

bool YN(bool b) {
	if (b)Yes;
	else No;
	return true;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const ll N = 200009;


signed main() {
	ll n; cin >> n;
	ll ans = 0;
	if (n >= 1e3) {
		ans += n - 999;
	}
	if (n >= 1e6) {
		ans += n - 999999;
	}
	if (n >= 1e9) {
		ans += n - 999999999;
	}
	if (n >= 1e12) {
		ans += n - 999999999999;
	}
	if (n >= 1e15) {
		ans += n - 999999999999999;
	}
	cout << ans << endl;
}





