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

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