#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int m;
    cin >> m;
    ll sum = 0, digit = 0;
    for(int i = 0; i < m; i++){
        ll d, c;
        cin >> d >> c;
        sum += d*c;
        digit += c;
    }
    cout << (sum-1)/9 + digit-1 << endl;
    return 0;
}