#include<iostream>
int main(){
	long long sum1 = 0;
	long long sum2 = 0;
	int n;
	std::cin >> n;
	for(int i=0;i<n;++i){
		long long a, b;
		std::cin >> a >> b;
		sum1 += b;
		sum2 += a * b;
	}
	std::cout << sum1 - 1 + (sum2 - 1) / 9 << std::endl;
}
