def main(): A, B, C, D = map(int, input().split()) for vegitable in range(A+1): if vegitable * C > B: break if vegitable * (C+1) > D: break print(vegitable-1) if __name__ == "__main__": main()