kari=list(input()) A=int(kari[0]) B=int(kari[1]) C=int(kari[2]) D=int(kari[3]) board=[] for i in range(1,A+1): veg = i meet = i * C total = veg + meet if veg <= A and meet <=B and total <= D: board.append(veg) else: break m=-1 for count in board: if count >= m: m=count print(m)