시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 256 MB 8 4 4 50.000%

문제

When Per was living in New York, he couldn’t use his debit card as often as in Sweden. He had to carry cash all the time and his wallet was getting heavy from all the coins he was carrying around. He was once in a candy store buying a few kilos of candy and he wanted to get rid of as many coins as possible but couldn’t figure out how to do it without getting any change back.

You will be given a price P that Per was going to pay. You will also be given the number of 1-, 5-, 10- and 25-cent coins that he had in his wallet. He didn’t have any notes. Find the maximum number of coins he could have used for paying the price P without getting any change back.

입력

The first line of input contains an integer P, 1 ≤ P ≤ 100 000 000, the price Per was going to pay. On the second line there are 4 space separated integers N1, N5, N10, N25; 0 ≤ N1, N5, N10, N25 ≤ 100 000 000, the number of 1-, 5-, 10- and 25-cent coins in Per’s wallet.

출력

If Per couldn’t pay exactly P without getting any change back, output Impossible on a single line. Otherwise output the maximum number of coins Per could use to pay the price P.

예제 입력

13
3 2 1 1

예제 출력

5

예제 입력 2

13
2 2 1 1

예제 출력 2

Impossible

힌트