#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;

int main() {
    long long M;
    cin>>M;
    long long sum=0;
    long long count=0;
    long long d[M];
    long long c[M];
    for(int i=0;i<M;i++){
        cin>>d[i]>>c[i];
        sum+=(d[i]*c[i]);
        count+=c[i];
    }
    cout<<((count-1)+((sum-1)/9))<<endl;


}



