A, B, C, D = map(int, raw_input().split()) ans = 0 for i in xrange(A+1): j = i * C if i + j <= D: ans = i print ans