leaf_max,drop,start,period = map(int,input().split()) start-=1 period-=1 current_month = 0 current_leaf = leaf_max while current_leaf > 0: d = drop cm = current_month % 12 if start <= cm <= start + period: d*=2 current_leaf-=d current_month+=1 print(current_month)