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 count=0; int count1=0,count2=0; int money=0; int sum=0; for(int i=p;i>=6;i=i-d){ sum+=i; count1++; } money=s-sum; while(true){ if(money>6){ money=money-6; count2++; } else break; } count=count1+count2; return count; } 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(); } }