#include using namespace std; int main(){ int x,y,z,n,i=1; cin >> x >> y >> z >> n; while(i < x){ if(z > 60){ z -=60; y++; } z+=n; i++; } cout << y<