import scala.math.{min,max}

object Main {
  val sc = new java.util.Scanner(System.in)
  def main(args: Array[String]) {
    val a,b,c,d = sc.nextInt
    val sum = a+b+c+d
    println(sum/60)
    println(sum%60)
  }
}