#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

void display_2int(vector<vector<int>> vec) {
    int N = vec.size();
    for (int i=0; i<N; i++) {
        for (int j=0; j<vec.at(i).size(); j++) {
            cout << vec.at(i).at(j);
            if (j < vec.at(i).size()-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}

void display_1string(vector<string> strlist) {
    int N = strlist.size();
    for (int i=0; i<N; i++) {
        cout << strlist.at(i) << endl;
    }
}

void display_1int(vector<int> intlist) {
    int N = intlist.size();
    if (N>0){
      for (int i=0; i<N - 1; i++) {
          cout << intlist.at(i) << " ";
      }
      cout << intlist.at(N-1) << endl;
    }else{
      cout << endl;
    }
}

void display_1ll(vector<long long> lllist) {
    long long N = lllist.size();
    if (N>0){
      for (int i=0; i<N - 1; i++) {
          cout << lllist.at(i) << " ";
      }
      cout << lllist.at(N-1) << endl;
    }else{
      cout << endl;
    }
}

void display_1pii(vector<pair<int, int>> plst){
  for (int i=0; i<plst.size(); i++){
    cout << plst.at(i).first << " " << plst.at(i).second << endl;
  }
}

int ctoi(char c) {
    if (c>='0' && c<='9'){
        return c - '0';
    }
    return -1;
}

ll count(ll N){
    string S = to_string(N);
    ll k = S.size();
    ll toridasi = (k-1)%3 + 1;
    ll rot = (k-1)/3;
    if (rot==0){
        return 0LL;
    }
    string s = "";
    for (int i=0; i<toridasi; i++){
        s += S.at(i);
    }
    ll n = stoll(s);
    string s1 = "";
    for (int i=toridasi; i<k; i++){
        s1 += S.at(i);
    }
    ll n1 = stoll(s);
    ll ans = (N - pow(1000LL, rot)+1LL) * rot + count(pow(1000LL, rot)-1LL);
    return ans;
}


int main(){
    ll N;
    cin >> N;
    cout << count(N) << endl;
}
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < n; ++i)
using namespace std;
typedef long long ll;
const int INF = 100100100;
int main() {
    ll n; cin >> n;
    ll ans=0;
    if(n>=1000) ans+=n-999;
    if(n>=1000000) ans+=n-999999;
    if(n>=1000000000) ans+=n-999999999;
    if(n>=1000000000000) ans+=n-999999999999;
    if(n>=1000000000000000) ans+=n-999999999999999;
    cout << ans << endl; return 0;
    
}