package test.demo; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Yukicoder740 { public static void main(String[] args) { try { String[]str=input(); int N =Integer.parseInt(str[0]); int M =Integer.parseInt(str[1]); int P =Integer.parseInt(str[2]); int Q =Integer.parseInt(str[3]); int sum=0; while(true) { for(int i=1;i<=12;i++) { //System.out.println(i+sum*12); if(i>=P&&i<=P+Q-1) { N=N-2*M; if(N<=0) { System.out.println(i+sum*12); return; } }else { N=N-M; if(N<=0) { System.out.println(i+sum*12); return; } } } sum++; } } catch (IOException e) { e.printStackTrace(); } } public static String[] input() throws IOException { BufferedReader br =new BufferedReader(new InputStreamReader(System.in)); String str=br.readLine(); String[]str2=str.split(" "); return str2; } }