#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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