#include <iostream>
using namespace std;

int main() {
    int m;
    cin >> m;
    long long ans = 0, sum = 0;
    for (int i = 0; i < m; i++) {
        long long d, c; cin >> d >> c;
        ans += c;
        sum += (d*c);
    }

    ans = ans + ((sum-1)/9) - 1;
    cout << ans << endl;
    return 0;
}