## Coin Change

View as PDF

Points: 7
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type

Given a value of cents, and an infinite supply of coins of denominations, followed by their denominations, find the least amount of coins required to make change for .

#### Input Specification

Line : , an integer between and .
Line : , the number of different denominations.
Line : the denominations of the coins.

#### Output Specification

An integer, on a single line - the least coins required to make change for .

#### Sample Input

24
4
12
13
5
6

#### Sample Output

2