N, M, P, Q = map(int, input().split()) current_month = 1 current_leaves = N answer = 0 end_month_storm = P + Q - 1 while current_leaves > 0: if P <= current_month <= end_month_storm: # Windy season remaining_storm = end_month_storm - current_month + 1 storm_reduce = remaining_storm * 2 * M if current_leaves <= storm_reduce: needed = (current_leaves + 2 * M - 1) // (2 * M) answer += needed break else: current_leaves -= storm_reduce answer += remaining_storm current_month = end_month_storm + 1 current_month = current_month % 12 if current_month == 0: current_month = 12 else: # Regular season if current_month < P: months_until_storm = P - current_month else: months_until_storm = (12 - current_month) + P normal_reduce = months_until_storm * M if current_leaves <= normal_reduce: needed = (current_leaves + M - 1) // M answer += needed break else: current_leaves -= normal_reduce answer += months_until_storm current_month += months_until_storm current_month = current_month % 12 if current_month == 0: current_month = 12 print(answer)