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

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