def coin(n, p, c):
    global count
    global m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
    else:
        return coin(n, p, c[1:])

n, m = map(int, input().split())

mon = list(map(int, input().split()))

mon.sort(reverse = True)

count = n

print(coin(n, 0, mon)) def coin(n, p, c):
    global count
    global m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
    else:
        return coin(n, p, c[1:]) coin global count global m if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
    else:
        return coin(n, p, c[1:]) n % c[0] == 0 n % c[0] n c[0] c 0 0 count = min(count, p + n // c[0]) count min(count, p + n // c[0]) min count p + n // c[0] p n // c[0] n c[0] c 0 return count count elif p + n // c[0] >= count:
        return n
     p + n // c[0] >= count p + n // c[0] p n // c[0] n c[0] c 0 count return n n elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
     c[0] < n c[0] c 0 n return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:])) min(coin(n - c[0], p + 1, c), coin(n, p, c[1:])) min coin(n - c[0], p + 1, c) coin n - c[0] n c[0] c 0 p + 1 p 1 c coin(n, p, c[1:]) coin n p c[1:] c 1: 1 return coin(n, p, c[1:]) coin(n, p, c[1:]) coin n p c[1:] c 1: 1 n n p p c c n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m mon = list(map(int, input().split())) mon list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split mon.sort(reverse = True) mon.sort mon sort reverse = True reverse True count = n count n print(coin(n, 0, mon)) print coin(n, 0, mon) coin n 0 mon m = map(int, input().split()) map(int, input().split()) m mon = list(map(int, input().split())) list(map(int, input().split())) mon def coin(n, p, c):
    global count
    global m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
    else:
        return coin(n, p, c[1:]) def coin(n, p, c):
    global count
    global m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
    else:
        return coin(n, p, c[1:]) coin n, m = map(int, input().split()) map(int, input().split()) n count = n n count
def coin(n, p, c):
    global count
    global m
    if n % c[0] == 0:
        count = min(count, p + n // c[0])
        return count
    elif p + n // c[0] >= count:
        return n
    elif c[0] < n:
        return min(coin(n - c[0], p + 1, c), coin(n, p, c[1:]))
    else:
        return coin(n, p, c[1:])

n, m = map(int, input().split())

mon = list(map(int, input().split()))

mon.sort(reverse = True)

count = n

print(coin(n, 0, mon))
