//#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<math.h>

//#define DIV 1000000007
#define TE 5e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N; cin >> N;

	ll cnt = 0, tens = 10;
	for (ll i = 1; i <= 16; i++) {
		ll p = (i - 1) / 3;
		if (N >= tens) {
			cnt += p*(tens / 10) * 9;
			//cout << "tens=" << tens << "cnt=" << cnt << endl;
		}

		else {
			cnt += (tens / 10) * p * (N / (tens / 10) - 1);
			cnt += p * (N % (tens / 10)+1);
			//cout << "tens=" << tens << "cnt=" << cnt << endl;
			break;
		}

		tens *= 10;
	}

	cout << cnt << endl;
}

#include <iostream>
#include <string>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int count = 0;
    while (true)
    {
        int a = s.find("ZONe");
        if (a == std::string::npos)
        {
            cout << count;
            return 0;
        }
        s = s.substr(a + 4, s.length() - (a + 4));
        count++;
    }
}