import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy int totalAmountSpent=0; int numberOfTimesdUsed=0; int numberOfItemsPurchased=0; if(p<=s) { totalAmountSpent = totalAmountSpent+p; numberOfItemsPurchased = numberOfItemsPurchased+1; while(totalAmountSpent<=s) { numberOfTimesdUsed = numberOfTimesdUsed +1; if((p-(d*numberOfTimesdUsed)) >=m) { if((totalAmountSpent +(p-(d*numberOfTimesdUsed)))<=s) { totalAmountSpent = totalAmountSpent +(p-(d*numberOfTimesdUsed)); numberOfItemsPurchased = numberOfItemsPurchased+1; } else { break; } } else { if((totalAmountSpent + m)<=s) { totalAmountSpent = totalAmountSpent + m; numberOfItemsPurchased = numberOfItemsPurchased+1; } else { break; } } } } return numberOfItemsPurchased; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int p = in.nextInt(); int d = in.nextInt(); int m = in.nextInt(); int s = in.nextInt(); int answer = howManyGames(p, d, m, s); System.out.println(answer); in.close(); } }