input_list = list(map(int,input().split())) n, m, p, q = input_list count_month = 0 cur_month = 1 rest_leaf = n while rest_leaf > 0: count_month += 1 if count_month % 12 == 0: cur_month = 12 else: cur_month = count_month % 12 if p <= cur_month and cur_month <= (p + q - 1): rest_leaf -= 2 * m else: rest_leaf -= m print(count_month)