A, B, C, D = map(int, input().split(' ')) ans = min(C//A if A != 0 else 1000, D//B if B != 0 else 1000) print(ans)