a,b,c,d=map(int,input().split()) v=[] for i in range(d+1): if i <= a and i*c+i <= d: v.append(i) print(max(v))