const input = require('fs') .readFileSync('/dev/stdin', 'utf8'); const [A, B, C, D] = input .split(/\s/) .map(v => +v); for (i = 0; i <= A; i++) if (i * C > B || i * (C + 1) > D) break; console.log(i - 1);