A,B,C,D = map(int,input().split()) i = 0 while i < A: i += 1 if C*i > B: i -= 1 break if i + C*i > D: i -= 1 break print(i)