n,m,p,q=map(int,input().split()) month=1;check=0;ans=0 while n>0: ans+=1 if month==p: check=q if check: n-=m*2 check-=1 else: n-=m if n<=0: break month+=1 if month>12: month=1 print(ans)