#include <algorithm>
#include <array>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
#define int long long
#define ll long long
#define pii std::pair<int, int>
#define pdd std::pair<double, double>
#define INF (1LL << 33)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define SHOW(p) \
    if (test)   \
        cout << #p " : " << p << endl;
bool test = false;
int ans, N;
int hoge(int x)
{
    if (x < 1000) {
        return 0;
    } else if (x < 1000000) {
        return x - 999;
    }
    int len = std::to_string(x).length();
    int co = (len - 1) / 3;
    int tmp = 1;
    REP(i, len - 1)
    {
        tmp *= 10;
    }
    if (tmp == x) {
        return co + hoge(x - 1);
    }
    return (x - tmp) * co + hoge(tmp);
}
signed main()
{
    test = true;
    cin >> N;
    cout << hoge(N) << endl;
    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<tuple>
#include<cstring>
#include<bitset>

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define pb push_back
#define eb emplace_back

#define INF 1000000000
#define INFLL 1000000000000000000LL

using namespace std;

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; }

using ll = long long;
using P = pair<ll, ll>;

#define MAX_N 1000+10

ll N;
pair<int, string> p[MAX_N];

int main() {

	cin >> N;
	REP(i, N)cin >> p[i].second >> p[i].first;

	sort(p, p + N, greater<pair<int, string>>());

	cout << p[1].second << endl;

	return 0;
}