#include <bits/stdc++.h>
# define rep(i,l,n) for(int i=l,i##_end=n;i<i##_end;++i)
# define rrep(i,n,l) for(int i=((int)(n)-1),i##_end=l;i>=i##_end;--i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    // 1. input
    ll N;
    cin>>N;

    // 2.
    ll ans = 0;
    ans += max(0LL,N - 999);
    ans += max(0LL,N - 999'999);
    ans += max(0LL,N - 999'999'999);
    ans += max(0LL,N - 999'999'999'999);
    ans += max(0LL,N - 999'999'999'999'999);

    // 3. output
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define mp        make_pair
#define pb        push_back
#define ppb       pop_back
#define all(x)    (x).begin(),(x).end()
#define int       long long
#define double    long double


void solve() {

	int n;
	cin >> n;

	int count = 0;

	int i = 0;

	for (i = 1000; i <= n; i *= 1000) {

		count += n - i + 1 ;



	}

	cout << count << "\n";



}

signed main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;

	while (t-- > 0) {
		solve();
	}

	return 0;
}
