open System

let m = stdin.ReadLine() |> int
let dc = [
    for _ in [1 .. m] ->
        let [|d; c|] = stdin.ReadLine().Split() |> Array.map int64
        (c, d*c) ]

let nd = List.sumBy fst dc
let sd = List.sumBy snd dc

printfn "%d" <| nd + (sd - 1L) / 9L - 1L