# -*- coding: utf-8 -*- a,b,c,d = map(int,input().split()) ideal = d // (c + 1) if b < ideal * c: ideal = b // c if a < ideal: ideal = a print(ideal)