import sequtils, strutils var n, h, m, t: int (n, h, m, t) = stdin.readLine.split.map parseInt var now = h * 60 + m now += n.pred * t echo now div 60 mod 24 echo now mod 60