#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF = 1001001001;

int main() {
  ll n;
  cin >> n;
  ll x = 1000;
  ll ans = 0;
  while(n+1 >= x){
    ans += n-(x-1);
    x *= 1000;
  }
  cout << ans << endl;
  return 0;    
}

#include <bits/stdc++.h>

//#include <atcoder/all>

using namespace std;
// using namespace atcoder;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}
long long pow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = pow(m, n / 2);
        return t * t;
    } else {
        return pow(m, n - 1) * m;
    }
}
bool bitcheck(ll x, ll y) { return (x >> y) & 1; }

template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}
map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}

// using mint = modint1000000007;
struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
vector<vector<ll>> adj;
bool warfloyd(vector<vector<ll>> graph) {
    adj = graph;
    for (int k = 0; k < graph.size(); k++) {
        for (int i = 0; i < graph.size(); i++) {
            for (int j = 0; j < graph.size(); j++) {
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }
    REP(i, graph.size()) {
        if (adj[i][i] != 0) {
            return true;
        }
    }
    return false;
}

#define DEBUG(x) cerr << #x << ": " << x << endl

int main() {
    ll n;
    cin >> n;
    if (n < 1000) {
        cout << 0 << endl;
    } else if (n < 1000000) {
        cout << n - 1000 + 1 << endl;
    } else if (n < 1000000000) {
        cout << 1000000 - 1000 + 2 * (n - 1000000 + 1) << endl;
    } else if (n < 1000000000000) {
        cout << 1000000 - 1000 + 2 * (1000000000 - 1000000) + 3 * (n - 1000000000 + 1) << endl;
    } else if (n < 1000000000000000) {
        cout << 1000000 - 1000 + 2 * (1000000000 - 1000000) + 3 * (1000000000000 - 1000000000) +
                    4 * (n - 1000000000000 + 1)
             << endl;
    } else {
        cout << 1000000 - 1000 + 2 * (1000000000 - 1000000) + 3 * (1000000000000 - 1000000000) +
                    4 * (n - 1000000000000 + 1) + 1
             << endl;
    }
}