from sys import stdin def main(): A, B, C, D = map(int, input().split()) ans = 0 for a in range(1, A + 1): meat = a * C if meat <= B and (a + meat) <= D: ans = a else: print(ans) break input = lambda: stdin.readline() main()