a,b,c,d=map(int,input().split()) print(max(0,min(min(a,b//c),d//-~c)))