import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int p = sc.nextInt(); int q = sc.nextInt(); int all = (12 + q) * m; int year = n / all; n %= all; for (int i = 1; i <= 12; i++) { n -= m; if (i >= p && i <= p + q - 1) { n -= m; } if (n <= 0) { System.out.println(year * 12 + i); return; } } } }