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