a,b,c,d = map(int,input().split()) cnt = 0 while(True): if((cnt+1)>a or (cnt+1)*c > b or cnt(cnt+1)+(cnt+1)*c>d): print(cnt) break cnt += 1