
object Main extends App {
  import scala.io.StdIn._

  val origin = Saturday
  val Array(ay, am, ad, by, bm, bd) = readLine.trim.split(' ').map(_.toLong)
  val from = Date(ay, am.toInt, ad.toInt)
  val to = Date(by, bm.toInt, bd.toInt)
  println(calBetween(from, to))
  def calBetween(from: Date, to: Date): Long = {
    if (from > to){
      0
    }else {
      val cen4 = (to.year - from.year - 1) / 400
      val epoch = Date(from.year + cen4 * 400, from.month, from.day)
      var count = cal4CenturyRelationalWeeksAt13 * cen4
      for (year ← epoch.year to to.year; month ← 1 to 12; d ← Some(Date(year, month, 13)) if epoch <= d && d <= to) {
        if (d.week == Friday) count += 1
      }
      count
    }
  }
  def cal4CenturyRelationalWeeksAt13: Int = {
    (for (year ← 0 until 400; month ← 1 to 12) yield {
      if (Date(year, month, 13).week == Friday) 1
      else 0
    }).sum
  }

  object Date {
    val monthFromNewYear = Array(0, 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31).also(a ⇒ a.indices.tail.foreach(i ⇒ a(i) += a(i - 1)))
  }
  object Week{
    val all = Array(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday)
  }
  sealed class Week(val toInt: Int) {
    def succ(n: Int): Week = {
      Week.all((toInt + n) % 7)
    }
  }
  case object Sunday extends Week(0)
  case object Monday extends Week(1)
  case object Tuesday extends Week(2)
  case object Wednesday extends Week(3)
  case object Thursday extends Week(4)
  case object Friday extends Week(5)
  case object Saturday extends Week(6)
  case class Date(year: Long, month: Int, day: Int) extends Ordered[Date] {
    def week: Week = Saturday.succ(RelationalYearDate((year % 400).toInt, month, day).daysFromEpoch)
    override def compare(that: Date): Int = {
      if (year != that.year) year.compare(that.year)
      else if (month != that.month) month.compare(that.month)
      else day.compare(that.day)
    }
  }

  object RelationalYearDate {
    val dayFromEpochUntilNewYear = Array.tabulate(400){year ⇒ if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) 366 else 365}.also{a ⇒
      a.indices.tail.reverse.foreach(i ⇒ a(i) = a(i - 1))
      a(0) = 0
      a.indices.tail.foreach(i ⇒ a(i) += a(i - 1))
    }
    def sumDays4Century = dayFromEpochUntilNewYear.last + 365
    val dayFromNewYearUntilMonth = Array(0, 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31).also(a ⇒ a.indices.tail.foreach(i ⇒ a(i) += a(i - 1)))
  }
  case class RelationalYearDate(year: Int, month: Int, day: Int) {
    def isLeapYear: Boolean = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)
    def daysFromEpoch: Int = if (isLeapYear && month > 2) RelationalYearDate.dayFromEpochUntilNewYear(year) + RelationalYearDate.dayFromNewYearUntilMonth(month) + day
    else RelationalYearDate.dayFromEpochUntilNewYear(year) + RelationalYearDate.dayFromNewYearUntilMonth(month) + day - 1
  }
  implicit class Scope[T](val value: T) extends AnyVal{
    @inline
    def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline
    def let[A](func: T ⇒ A): A = func(value)

  }
}
