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

#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

int main() {
  ll n;
  cin >> n;
  ll x = 1000;
  ll ans = 0;
  while(n-x+1 >= 1) {
    ans += n-x+1;
    x*=1000;
  }
  
  cout << ans << endl;
  return 0;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define ar array 
clock_t time_req = clock()*1.0/CLOCKS_PER_SEC;

bool slope(pair<int,int> a , pair<int,int> b , pair<int,int> c){
    return (b.second-a.second)*(c.first-b.first) == (c.second-b.second)*(b.first-a.first);
}

#define int ll
void test_case() {
   int n;
   cin >> n;
   if(n <= 999){
    cout<<"0\n";
    return;
   }
   // int ans2 = 0;
   // for(int i = 999 ; i <= n ; i++){
   //  if(i > 999 && i < 1000000)
   //    ans2++;
   //  if(i >= 1000000 && i < 1000000000)
   //    ans2+=2;
   // }
   // cout<<ans2<<"\n";
   if(n >= 999 && n < 1000000){
    cout<<n-999<<"\n";
    return;
   }
   if(n >= 1000000 && n < 1000000000){
    int ans = (n-999999)*2 + (999999-999);
    cout<<ans<<"\n";
    return;
   }
   if(n >= 1000000000 && n < 1000000000000){
    int ans = (n-999999999)*3+(999999999-999999)*2+(999999-999);
    cout<<ans<<"\n";
    return;
   }
   if(n >= 1000000000000 && n < 1000000000000000){
    int ans = (n-999999999999)*4+(999999999999-999999999)*3+(999999999-999999)*2+(999999-999);
    cout<<ans<<"\n";
    return;
   }
   else{
    // int ans = (n-999999999999)*4+(999999999999-999999999)*3+(999999999-999999)*2+(999999-999);
    cout<<3998998998999005<<"\n";
   }


}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    int T = 1;
    // cin >> T;
    while(T--){
        test_case();
    }
}

// dont take stress
// remember the i , j index in double loop
// typing slow but dont make mistake while thinking and typing

//(x,y) , (x1,y1) , (x2,y2)
// (y1-y)/(x1-x) == (y2-y1)/(x2-x1)
// (y1-y)*(x2-x1) == ()s

