
#include "bits/stdc++.h"
using namespace std;

int main(){
    int64_t n, a = 0; cin >> n;
    if (n >= 1000) a += n - 999;
    if (n >= 1000000) a += n - 999999;
    if (n >= 1000000000) a += n - 999999999;
    if (n >= 1000000000000) a += n - 999999999999;
    if (n >= 1000000000000000) a += n - 999999999999999;
    cout << a << endl;
}
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
// warning: pragmas don't work on USACO and just set to O0

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //gp_hash_table<T, U, chash>;
#include <ext/pb_ds/tree_policy.hpp> //tree<T, U, cmp, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std; using namespace __gnu_pbds;
// shorter template (CF specialization, because compile time better)

inline int RAND(int l, int r) {
    mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> unifd(l, r); return unifd(mt);
}

template <class T> using pq = priority_queue<T, vector<T>, greater<T>>;
using ll = long long; using db = double; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>;
using vll = vector<ll>; const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};

#define ff first
#define ss second
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define pf push_front

//#define TC
const ll INF = 1e18; const db EPS = 1e-8;
const int MOD = 1e9 + 7, //998244353
          _ = 2e5 + 5;


void solve() {
    ll N;
    cin>>N;
    ll x=1;
    ll ans=0;
    ll y=1;
    while(true){
        x*=1000;
        if(N>=x) {
            ll res = (min(x*1000,N+1)-x)*y;
            ans+=res;
        }
        else {
            break;
        }
        y++;
    }
    cout<<ans;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    cin.tie(0)->sync_with_stdio(0); //cout << setprecision(3) << fixed << showpoint;
    int t = 1;

    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}