import std.algorithm; import std.array; import std.conv; import std.math; import std.range; import std.stdio; import std.string; import std.typecons; T read(T)() { return readln.chomp.to!T; } T[] reads(T)() { return readln.split.to!(T[]); } alias readint = read!int; alias readints = reads!int; int calc(int a, int b, int c, int d) { for (int i = a; i >= 0; i--) { if (i * c <= b && i + i * c <= d) { return i; } } return 0; } void main() { auto xs = readints; int a = xs[0], b = xs[1], c = xs[2], d = xs[3]; writeln(calc(a, b, c, d)); }