/*No.804 野菜が苦手*/ import java.io.*; public class No804{ public static void main(String[] args) { try(BufferedReader input =new BufferedReader(new InputStreamReader(System.in))){ String[]s_input=input.readLine().split(" "); byte ordered_vegetables=Byte.parseByte(s_input[0]); byte ordered_meat=Byte.parseByte(s_input[1]); byte multiple=Byte.parseByte(s_input[2]); byte capacity=Byte.parseByte(s_input[3]); while(ordered_vegetables*multiple>ordered_meat){ ordered_vegetables--; } while(ordered_vegetables+ordered_meat>capacity){ ordered_vegetables--; ordered_meat-=multiple; } System.out.println(ordered_vegetables); }catch(Exception e){ e.printStackTrace(); } } }