#include <iostream>
using namespace std;
int m,d[200000];
long long c[200000],sum,num;
int main(){
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>d[i]>>c[i];
        sum+=d[i]*c[i];
        num+=c[i];
    }
    cout<<(sum-1)/9+num-1<<endl;
}