from collections import * from itertools import * from functools import * from heapq import * import sys,math # input = sys.stdin.readline A,B,C,D = map(int,input().split()) now = 0 for i in range(1,A+1): if(C*i<=B)&((C+1)*i<=D): continue else: print(i-1) exit()