这个让我想到了Halmilton路径的 2进制表达 代表是否取到这个点
m, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(1,1<<n):
tp, ct = 1, -1
a = ["0"]*(n+2-len(bin(i))) + list(bin(i)[2:])
for i in range(n):
if a[i] == "1":
ct *= -1
tp *= p[i]
ans += ct*(m//tp)
print(ans)