CF BUDDY
← Problems·

1068A · Birthday

1400 · math

Problem: Ivan is collecting coins. There are only NN different collectible coins, Ivan has KK of them. He will be celebrating his birthday soon, so all his MM freinds decided to gift him coins. They all agreed to three terms:

  • Everyone must gift as many coins as others.
  • All coins given to Ivan must be different.
  • Not less than LL coins from gifts altogether, must be new in Ivan's collection.

But his friends don't know which coins have Ivan already got in his collection. They don't want to spend money so they want to buy minimum quantity of coins, that satisfy all terms, irrespective of the Ivan's collection. Help them to find this minimum number of coins or define it's not possible to meet all the terms.

Input Format: The only line of input contains 4 integers NN, MM, KK, LL (1KN10181 \le K \le N \le 10^{18}; 1M,L10181 \le M, \,\, L \le 10^{18}) — quantity of different coins, number of Ivan's friends, size of Ivan's collection and quantity of coins, that must be new in Ivan's collection.

Output Format: Print one number — minimal number of coins one friend can gift to satisfy all the conditions. If it is impossible to satisfy all three conditions print "-1" (without quotes).

Note: In the first test, one coin from each friend is enough, as he will be presented with 15 different coins and 13 of them will definitely be new.

In the second test, Ivan has 11 friends, but there are only 10 different coins. So all friends can't present him different coins.

Sample Cases

Case 1

Input

20 15 2 3

Output

1

Case 2

Input

10 11 2 4

Output

-1

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback