#include <cstdio>
int m, d;
long long len, sum, c;

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