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