import java.io.*; import java.util.*; /** * * @author akashvermaofskt * Coding is love <3! */ class AHack { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static StringTokenizer st = null; static String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } static int nextInt() { return Integer.parseInt(next()); } static long nextLong() { return Long.parseLong(next()); } public static void main(String args[]) { try { int p=nextInt(); int d=nextInt(); int m=nextInt(); int s=nextInt(); long ans=0; long cost=d; if(p<=s){ int i; for (i = p; i >=m && i<=s; i-=d) { ans++; s-=i; //System.out.println("i "+i); } if(i