#include <iostream>
#include <cstdint>

using Int = std::int64_t;

int main() {
	int m;
	std::cin >> m;

	Int s = 0, w = 0;
	for (int i = 0; i < m; ++i) {
		Int d, c;
		std::cin >> d >> c;

		w += c;
		s += d * c;
	}

	std::cout << w - 1 + (s - 1) / 9 << std::endl;
}