import java.util.Scanner; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(), M = sc.nextInt(), P = sc.nextInt(), Q = sc.nextInt(), i; sc.close(); for (i = 0; N > 0; ++i) { if (i % 12 + 1 >= P && i % 12 + 1 < P + Q) N -= 2 * M; else N -= M; } System.out.print(i); } }