def main(): a, b, c, d = map(int, input().split(' ')) vege = 0 while d - vege * (1+c) <= 1 + c and vege <= a and vege * c <= b: vege += 1 print(vege) if __name__ =='__main__': main()