n,m,p,q=map(int,input().split()) for i in range(1,10**6+1): n-=m n-=m*(p<=(i-1)%12+1<=p+q-1) if n<=0: print(i) exit()