#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
	int m;
	scanf("%d",&m);
	ll sum=0,dig=0;
	for(int i=0;i<m;i++)
	{
		ll d,c;
		scanf("%lld %lld",&d,&c);
		sum+=d*c;
		dig+=c;
	}
	printf("%lld\n",dig+(sum-1)/9LL-1);
	return 0;
}