#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
const i64 LLINF = (1LL << 60);

int M;
int d;
i64 c;
i64 sum = 0;
i64 digit = 0;

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

    return ( 0 );
}
