import java.util.*; class Main{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); int i; for(i = 1; i <= a && i*c <= b && i*c+i <= d; i++){ } System.out.print(--i); } }