B - Flowers Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 8

問題文

高橋君は、A 本の赤い花と B 本の青い花からなる花束をたくさん作りたいです。

赤い花を X 本、青い花を Y 本持っているとき、最大で何個の花束を作れますか?

制約

  • 1 \leq A,B \leq 100
  • 0 \leq X,Y \leq 100
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

A B X Y

出力

作れる花束の個数の最大値を出力せよ。


入力例 1

3 2 6 4

出力例 1

2

花束は 2 つ作ることが可能です。


入力例 2

3 3 100 0

出力例 2

0

入力例 3

5 10 30 23

出力例 3

2

Score : 8 points

Problem Statement

Takahashi wants to make many bouquets. Each bouquet should consist of A red flowers and B blue flowers.

Takahashi has X red flowers and Y blue flowers. How many bouquets can he make at most?

Constraints

  • 1 \leq A,B \leq 100
  • 0 \leq X,Y \leq 100
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B X Y

Output

Print the maximum number of bouquets that Takahashi can make.


Sample Input 1

3 2 6 4

Sample Output 1

2

He can make 2 bouquets.


Sample Input 2

3 3 100 0

Sample Output 2

0

Sample Input 3

5 10 30 23

Sample Output 3

2