from itertools import product

class DP:
    def __init__(self, value, variety, coins):
        self.value = value
        self.variety = variety
        self.coins = coins
        self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]
        self.DPinit()

    def DPinit(self):
        for row in self.DP:
            row[1] = 1
        self.DP[0] = [i for i in range(self.value + 1)]

    def DPcomp(self):
        for (m, n) in product(list(range(1, self.variety)),list(range(self.value + 1))):
                self.DP[m][n] = self.numberOfCoin(m, n)

    def numberOfCoin(self, m, n):
        if n >= self.coins[m]:
            return min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1)
        else:
            return self.DP[m - 1][n]

    def answer(self):
        self.DPcomp()
        return self.DP[self.variety - 1][self.value]


if __name__ == "__main__":
    status = list(map(int,input().split()))
    coins = list(map(int,input().split()))
    dp = DP(status[0],status[1],coins)
    print(dp.answer()) from itertools import product class DP:
    def __init__(self, value, variety, coins):
        self.value = value
        self.variety = variety
        self.coins = coins
        self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]
        self.DPinit()

    def DPinit(self):
        for row in self.DP:
            row[1] = 1
        self.DP[0] = [i for i in range(self.value + 1)]

    def DPcomp(self):
        for (m, n) in product(list(range(1, self.variety)),list(range(self.value + 1))):
                self.DP[m][n] = self.numberOfCoin(m, n)

    def numberOfCoin(self, m, n):
        if n >= self.coins[m]:
            return min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1)
        else:
            return self.DP[m - 1][n]

    def answer(self):
        self.DPcomp()
        return self.DP[self.variety - 1][self.value] DP def __init__(self, value, variety, coins):
        self.value = value
        self.variety = variety
        self.coins = coins
        self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]
        self.DPinit()

     __init__ self.value = value self.value self value value self.variety = variety self.variety self variety variety self.coins = coins self.coins self coins coins [0 for _ in range(value + 1)] for _ in range(variety) for _ in range(variety) _ range(variety) range variety for _ in range(variety) [0 for _ in range(value + 1)] self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)] self.DP self DP [[0 for _ in range(value + 1)] for _ in range(variety)] self.DPinit() self.DPinit self DPinit self self value value variety variety coins coins def DPinit(self):
        for row in self.DP:
            row[1] = 1
        self.DP[0] = [i for i in range(self.value + 1)]

     DPinit for row in self.DP:
            row[1] = 1
         row self.DP self DP row[1] = 1 row[1] row 1 1 i for i in range(self.value + 1) for i in range(self.value + 1) i range(self.value + 1) range self.value + 1 self.value self value 1 for i in range(self.value + 1) i self.DP[0] = [i for i in range(self.value + 1)] self.DP[0] self.DP self DP 0 [i for i in range(self.value + 1)] self self def DPcomp(self):
        for (m, n) in product(list(range(1, self.variety)),list(range(self.value + 1))):
                self.DP[m][n] = self.numberOfCoin(m, n)

     DPcomp for (m, n) in product(list(range(1, self.variety)),list(range(self.value + 1))):
                self.DP[m][n] = self.numberOfCoin(m, n)

     (m, n) m n product(list(range(1, self.variety)),list(range(self.value + 1))) product list(range(1, self.variety)) list range(1, self.variety) range 1 self.variety self variety list(range(self.value + 1)) list range(self.value + 1) range self.value + 1 self.value self value 1 self.DP[m][n] = self.numberOfCoin(m, n) self.DP[m][n] self.DP[m] self.DP self DP m n self.numberOfCoin(m, n) self.numberOfCoin self numberOfCoin m n self self def numberOfCoin(self, m, n):
        if n >= self.coins[m]:
            return min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1)
        else:
            return self.DP[m - 1][n]

     numberOfCoin if n >= self.coins[m]:
            return min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1)
        else:
            return self.DP[m - 1][n]

     n >= self.coins[m] n self.coins[m] self.coins self coins m return min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1) min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1) min self.DP[m - 1][n] self.DP[m - 1] self.DP self DP m - 1 m 1 n self.DP[m][n - self.coins[m]] + 1 self.DP[m][n - self.coins[m]] self.DP[m] self.DP self DP m n - self.coins[m] n self.coins[m] self.coins self coins m 1 return self.DP[m - 1][n] self.DP[m - 1][n] self.DP[m - 1] self.DP self DP m - 1 m 1 n self self m m n n def answer(self):
        self.DPcomp()
        return self.DP[self.variety - 1][self.value] answer self.DPcomp() self.DPcomp self DPcomp return self.DP[self.variety - 1][self.value] self.DP[self.variety - 1][self.value] self.DP[self.variety - 1] self.DP self DP self.variety - 1 self.variety self variety 1 self.value self value self self if __name__ == "__main__":
    status = list(map(int,input().split()))
    coins = list(map(int,input().split()))
    dp = DP(status[0],status[1],coins)
    print(dp.answer()) __name__ == "__main__" __name__ "__main__" status = list(map(int,input().split())) status list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split coins = list(map(int,input().split())) coins list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split dp = DP(status[0],status[1],coins) dp DP(status[0],status[1],coins) DP status[0] status 0 status[1] status 1 coins print(dp.answer()) print dp.answer() dp.answer dp answer status = list(map(int,input().split())) list(map(int,input().split())) status class DP:
    def __init__(self, value, variety, coins):
        self.value = value
        self.variety = variety
        self.coins = coins
        self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]
        self.DPinit()

    def DPinit(self):
        for row in self.DP:
            row[1] = 1
        self.DP[0] = [i for i in range(self.value + 1)]

    def DPcomp(self):
        for (m, n) in product(list(range(1, self.variety)),list(range(self.value + 1))):
                self.DP[m][n] = self.numberOfCoin(m, n)

    def numberOfCoin(self, m, n):
        if n >= self.coins[m]:
            return min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1)
        else:
            return self.DP[m - 1][n]

    def answer(self):
        self.DPcomp()
        return self.DP[self.variety - 1][self.value] class DP:
    def __init__(self, value, variety, coins):
        self.value = value
        self.variety = variety
        self.coins = coins
        self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]
        self.DPinit()

    def DPinit(self):
        for row in self.DP:
            row[1] = 1
        self.DP[0] = [i for i in range(self.value + 1)]

    def DPcomp(self):
        for (m, n) in product(list(range(1, self.variety)),list(range(self.value + 1))):
                self.DP[m][n] = self.numberOfCoin(m, n)

    def numberOfCoin(self, m, n):
        if n >= self.coins[m]:
            return min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1)
        else:
            return self.DP[m - 1][n]

    def answer(self):
        self.DPcomp()
        return self.DP[self.variety - 1][self.value] DP coins = list(map(int,input().split())) list(map(int,input().split())) coins dp = DP(status[0],status[1],coins) DP(status[0],status[1],coins) dp
from itertools import product

class DP:
    def __init__(self, value, variety, coins):
        self.value = value
        self.variety = variety
        self.coins = coins
        self.DP = [[0 for _ in range(value + 1)] for _ in range(variety)]
        self.DPinit()

    def DPinit(self):
        for row in self.DP:
            row[1] = 1
        self.DP[0] = [i for i in range(self.value + 1)]

    def DPcomp(self):
        for (m, n) in product(list(range(1, self.variety)),list(range(self.value + 1))):
                self.DP[m][n] = self.numberOfCoin(m, n)

    def numberOfCoin(self, m, n):
        if n >= self.coins[m]:
            return min(self.DP[m - 1][n], self.DP[m][n - self.coins[m]] + 1)
        else:
            return self.DP[m - 1][n]

    def answer(self):
        self.DPcomp()
        return self.DP[self.variety - 1][self.value]


if __name__ == "__main__":
    status = list(map(int,input().split()))
    coins = list(map(int,input().split()))
    dp = DP(status[0],status[1],coins)
    print(dp.answer())