def main(): a, b, c, d = (int(x) for x in input().split()) ans = 0 for vege in range(a+1): meat = vege * c if meat <= b and vege + meat <= d: ans = vege print(ans) if __name__ == '__main__': main()