def main():
    n, m = map(int, input().split())
    mo = list(map(int, input().split()))
    dp = [float("inf") for i in range(n + 2)]
    dp[0] = 0
    for i in range(n + 1):
        for j in mo:
            if i + j <= n:
                temp_index = i + j
                dp[temp_index] = min(dp[temp_index], dp[i] + 1)
    print(dp[n])


if __name__ == '__main__':
    main()
 def main():
    n, m = map(int, input().split())
    mo = list(map(int, input().split()))
    dp = [float("inf") for i in range(n + 2)]
    dp[0] = 0
    for i in range(n + 1):
        for j in mo:
            if i + j <= n:
                temp_index = i + j
                dp[temp_index] = min(dp[temp_index], dp[i] + 1)
    print(dp[n]) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m mo = list(map(int, input().split())) mo list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split float("inf") for i in range(n + 2) for i in range(n + 2) i range(n + 2) range n + 2 n 2 for i in range(n + 2) float("inf") float "inf" dp = [float("inf") for i in range(n + 2)] dp [float("inf") for i in range(n + 2)] dp[0] = 0 dp[0] dp 0 0 for i in range(n + 1):
        for j in mo:
            if i + j <= n:
                temp_index = i + j
                dp[temp_index] = min(dp[temp_index], dp[i] + 1)
     i range(n + 1) range n + 1 n 1 for j in mo:
            if i + j <= n:
                temp_index = i + j
                dp[temp_index] = min(dp[temp_index], dp[i] + 1)
     j mo if i + j <= n:
                temp_index = i + j
                dp[temp_index] = min(dp[temp_index], dp[i] + 1)
     i + j <= n i + j i j n temp_index = i + j temp_index i + j i j dp[temp_index] = min(dp[temp_index], dp[i] + 1) dp[temp_index] dp temp_index min(dp[temp_index], dp[i] + 1) min dp[temp_index] dp temp_index dp[i] + 1 dp[i] dp i 1 print(dp[n]) print dp[n] dp n if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    n, m = map(int, input().split())
    mo = list(map(int, input().split()))
    dp = [float("inf") for i in range(n + 2)]
    dp[0] = 0
    for i in range(n + 1):
        for j in mo:
            if i + j <= n:
                temp_index = i + j
                dp[temp_index] = min(dp[temp_index], dp[i] + 1)
    print(dp[n]) def main():
    n, m = map(int, input().split())
    mo = list(map(int, input().split()))
    dp = [float("inf") for i in range(n + 2)]
    dp[0] = 0
    for i in range(n + 1):
        for j in mo:
            if i + j <= n:
                temp_index = i + j
                dp[temp_index] = min(dp[temp_index], dp[i] + 1)
    print(dp[n]) main
def main():
    n, m = map(int, input().split())
    mo = list(map(int, input().split()))
    dp = [float("inf") for i in range(n + 2)]
    dp[0] = 0
    for i in range(n + 1):
        for j in mo:
            if i + j <= n:
                temp_index = i + j
                dp[temp_index] = min(dp[temp_index], dp[i] + 1)
    print(dp[n])


if __name__ == '__main__':
    main()

