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