import sys

input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    C = list(map(int, input().split()))

    INF = 10 ** 18
    dp = [INF] * (N + 1)
    dp[0] = 0
    for c in C:
        for i in range(c, N + 1):
            dp[i] = min(dp[i], dp[i - c] + 1)

    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()
 import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    N, W = map(int, input().split())
    C = list(map(int, input().split()))

    INF = 10 ** 18
    dp = [INF] * (N + 1)
    dp[0] = 0
    for c in C:
        for i in range(c, N + 1):
            dp[i] = min(dp[i], dp[i - c] + 1)

    ans = dp[-1]
    print(ans) main N, W = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split W C = list(map(int, input().split())) C list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split INF = 10 ** 18 INF 10 ** 18 10 18 dp = [INF] * (N + 1) dp [INF] * (N + 1) [INF] INF N + 1 N 1 dp[0] = 0 dp[0] dp 0 0 for c in C:
        for i in range(c, N + 1):
            dp[i] = min(dp[i], dp[i - c] + 1)

     c C for i in range(c, N + 1):
            dp[i] = min(dp[i], dp[i - c] + 1)

     i range(c, N + 1) range c N + 1 N 1 dp[i] = min(dp[i], dp[i - c] + 1) dp[i] dp i min(dp[i], dp[i - c] + 1) min dp[i] dp i dp[i - c] + 1 dp[i - c] dp i - c i c 1 ans = dp[-1] ans dp[-1] dp -1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.readline sys.stdin.readline input def main():
    N, W = map(int, input().split())
    C = list(map(int, input().split()))

    INF = 10 ** 18
    dp = [INF] * (N + 1)
    dp[0] = 0
    for c in C:
        for i in range(c, N + 1):
            dp[i] = min(dp[i], dp[i - c] + 1)

    ans = dp[-1]
    print(ans) def main():
    N, W = map(int, input().split())
    C = list(map(int, input().split()))

    INF = 10 ** 18
    dp = [INF] * (N + 1)
    dp[0] = 0
    for c in C:
        for i in range(c, N + 1):
            dp[i] = min(dp[i], dp[i - c] + 1)

    ans = dp[-1]
    print(ans) main
import sys

input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    C = list(map(int, input().split()))

    INF = 10 ** 18
    dp = [INF] * (N + 1)
    dp[0] = 0
    for c in C:
        for i in range(c, N + 1):
            dp[i] = min(dp[i], dp[i - c] + 1)

    ans = dp[-1]
    print(ans)


if __name__ == "__main__":
    main()

