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