import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)


  val M = in.next().toInt

  var ans = (M-1).toLong
  var over = 0L // 繰越し
  for (_ <- 1 to M) {
    val d, c = in.next().toLong

    ans += c - 1
    var now = d * c + over

    while (now >= 10) {
      val num = now / 10
      ans += num

      now = now % 10 + num
    }

    over = now
  }

  // val a = new Array[Int](N)

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
