#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define endl "\n"
#define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll mod = 1e9 + 7;
// const ll mod = 998244353;
const ll sz = 2e5 + 1;
vector<ll> fac(sz, 1), ifac(sz);
vector<int> prime(sz);

ll mpow(ll a, ll b = mod-2, ll m = mod) {
    ll res = 1; a %= m; assert(b >= 0);
    for(; b; b >>= 1) { if(b & 1) res = res*a % m; a = a*a % m; }
    return res;
}
void init() {
    for (ll i = 2; i < sz; i++)
        fac[i] = (fac[i-1] * i) % mod;
    ifac[sz-1] = mpow(fac[sz-1]);
    for (ll i = sz-2; i >= 0; i--)
        ifac[i] = (ifac[i+1] * (i+1)) % mod;
    
    for (int i = 2; i < sz; i++)
        prime[i] = i;
    for (ll i = 2; i*i < sz; i++) {
        if (prime[i] != i)  continue;
        for (ll j = i*i; j < sz; j += i)
            if (prime[j] == j)  prime[j] = i;
    }
}
ll nCr(ll n, ll r) {
    if (n < r) return 0;
    return (fac[n] * (ifac[r] * ifac[n-r] % mod)) % mod;
}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a / gcd(a,b)) * b; }

void solve() {
    string s;
    cin >> s;
    
    int n = s.size();
    if (n <= 3) {
        cout << 0 << endl;
        return ;
    }
    
    vector<ll> vals(n);
    
    ll prod = 1, res = 0;
    for (int i = n-1; i > 0; i--) {
        ll pos = n - i - 1;
        ll cnt = 9 * prod;
        
        res += (cnt * (pos / 3));
        
        prod *= 10;
        vals[i] = prod;
    }
    
    for (int i = 0; i < n-1; i++) {
        ll cnt;
        if (i == 0)     cnt = s[i] - '1';
        else            cnt = s[i] - '0';
        
        ll val = cnt * vals[i+1];
        res += (val * ((n-1)/3));
    }
    
    res += ((s[n-1]-'0' + 1) * ((n-1)/3));
    
    cout << res<< endl;
}

int main() {
    ios_base::sync_with_stdio(false);   cin.tie(NULL);  cout.tie(NULL);
    // init();
    
    int t = 1;
    // cin >> t;
    
    while(t--)
        solve();
    
	return 0;
}
#include<bits/stdc++.h>
using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int tt; cin>>tt; while(tt--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++)
#define for1(i,low,high) for(int i=low;i<high;i++)
#define for2(i,low,high) for(int i=low;i<=high;i++)
#define rev(i,high,low)  for(int i=high;i>=low ;i--)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
void i_o() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
#endif
}

int main()
{
    boost; i_o();
    ll n; cin>>n;
    ll ans=0;
    ans+=max(0LL,min(999999-999LL,n-999));
    ans+=max(0LL,min(999999999LL-999999,n-999999))*2LL;
    ans+=max(0LL,min(999999999999LL-999999999,n-999999999LL))*3LL;
    ans+=max(0LL,min(999999999999999L-999999999999LL,n-999999999999LL))*4LL;
    ans+=max(0LL,min(999999999999999999L-999999999999999LL,n-999999999999999LL))*5LL;
    cout<<ans<<endl;

    return 0;
}

