program Digit_Sum_Replace
  implicit none
  integer :: m, i
  integer(8) :: d, c, tot = 0_8, cnt = 0_8
  read(*,*) m
  do i = 1, m
    read(*,*) d, c
    tot = tot+d*c
    cnt = cnt+c
  end do
  write(*,'(i0)') cnt+tot/10_8-1_8
end program Digit_Sum_Replace