A, B, C, D = map(int,input().split()) ans = 0 while ans*(C+1) <= D and ans <= A and ans*C <= B: ans += 1 print(ans-1)