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