A,B,C,D = map(int,input().split()) count = 0 while D-(C+1) >= 0 and A > 0 and B >= C: B -= C A -= 1 D -= C+1 count += 1 print(count)