import java.util.*

fun main(args: Array<String>) {
    var sum = 0L
    var res = 0L

    val M = readLine()!!.toInt()

    for (i in 1 .. M) {
        val (d, c) = readLine()!!.split(" ").map{it.toLong()}

        sum += d * c
        res += c
    }

    res--

    res += (sum - 1) / 9

    println(Math.max(res, 1))
}
