# coding: utf-8 a, b, c, d = map(int, input().split()) lim = [101, 101, 101] lim[0] = d // (1 + c) if a < lim[0]: lim[1] = a if lim[0] * c > b: lim[2] = b // c print(min(lim))