s = io.read() hour, min, pm, utc = string.match(s, "(%d+) (%d+) UTC([%+%-])([%.%d]+)") hour, min, utc = tonumber(hour), tonumber(min), tonumber(utc) if(pm == "-") then utc = -utc end v = (hour + utc - 9) * 60 + min v = v % 1440 print(string.format("%02d:%02d", math.floor(v / 60), v % 60))