import java.util.Scanner

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val nums = List.fill(6)(sc.nextLine()).map(_.toLong)

    val times = nums.zip(nums.tail).map {
      case (a, b) =>
        val div = a / b
        val remain = a % b
        if (remain != 0) div + 1 else div
    }
    val gaps = times.zip(times.tail).map {
      case (a, b) =>
        val g = b - a
        if (g < 0) 0 else g
    }

    val r = times.head + gaps.sum + 4
    println(r)
  }

}
