
object Main extends App {

  import scala.io.StdIn._

  val Array(y, m, d) = readLine.trim.split(' ').map(_.toInt)
  val Array(z, n, e) = readLine.trim.split(' ').map(_.toInt)
  val diff = Date(y, m, d) - Date(z, n, e)
  println(
    (diff.abs + 371) / 372
  )
  case class Date(year: Int, month: Int, day: Int) {
    def -(that: Date): Int = toInt - that.toInt
    private def toInt: Int = year * 372 + (month - 1) * 31 + day - 1
  }
}

