#include"bits/stdc++.h"
using namespace std;

int main() {
    int64_t M;
    cin >> M;
    vector<int64_t> d(M), c(M);
    int64_t sum = 0, digit_sum = 0;
    for (int64_t i = 0; i < M; i++) {
        cin >> d[i] >> c[i];
        sum += d[i] * c[i];
        digit_sum += c[i];
    }

    int64_t ans = digit_sum - 1 + (sum - 1) / 9;
    cout << ans << endl;
}