import scala.io.StdIn.readLine

object Main {
  def main(args:Array[String]) = {
    val n = readLine.split(" ").map(_.toInt)
    if(n(0) + n(1)*5 + n(2)*10 + n(3)*50 + n(4)*100 + n(5)*500 >= 1000)
      println(1)
    else
      println(0)
  }
}