a,b,c,d = map(int,input().split()) print(min(d//(1+c),a,b//c))