process.stdin.resume(); process.stdin.setEncoding('ascii'); var input_stdin = ""; var input_stdin_array = ""; var input_currentline = 0; process.stdin.on('data', function (data) { input_stdin += data; }); process.stdin.on('end', function () { input_stdin_array = input_stdin.split("\n"); main(); }); function readLine() { return input_stdin_array[input_currentline++]; } /////////////// ignore above this line //////////////////// function howManyGames(p, d, m, s) { var dollarsSpent =0; var count =0; var currentCost =p; while (dollarsSpent <= s) { if(count ==0) { dollarsSpent = p; } else if(currentCost-d >= m) { currentCost -= d; dollarsSpent +=currentCost; } else{ currentCost=m; dollarsSpent +=currentCost; } if(dollarsSpent <= s) count+=1; //console.info(s + " " + dollarsSpent + " " + p + " "+ d + " " + currentCost + " " + m); } return count; } function main() { var p_temp = readLine().split(' '); var p = parseInt(p_temp[0]); var d = parseInt(p_temp[1]); var m = parseInt(p_temp[2]); var s = parseInt(p_temp[3]); var answer = howManyGames(p, d, m, s); process.stdout.write("" + answer + "\n"); }