veg,meat,mul,limit = map(int,input().split()) vegs = [] for i in range(1,veg+1): for j in range(1,meat+1): if j == i*mul: if limit >= i+j: vegs.append(i) else: vegs.append(0) else: vegs.append(0) print(vegs) print(max(vegs))