#include using namespace std; int n,h,m,t; int main(){ cin>>n>>h>>m>>t; m+=(n-1)*t; h+=m/60; m%=60; h%=24; cout<