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,1001): if(i<=A)&(C*i<=B)&((C+1)*i<=D): continue else: print(i-1) exit()