死活卡不进2s
#include<bits/stdc++.h>
#define N 1000000005
#define int long long
#define ull unsigned long long
using namespace std;
namespace IO{
template<typename T> inline void write(T x){
if(x<0) putchar('-'),x=-x;
if(x==0){
putchar('0'); return ;
}
if(x>9) write(x/10);
putchar(x%10+'0');
return ;
}
template<typename T> inline void read(T &x){
x=0; int w=1; char ch=getchar();
while(!isdigit(ch)){
if(ch=='-') w=-1; ch=getchar();
}
while(isdigit(ch))
x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
x*=w; return ;
}
}
using namespace IO;
ull bs[(N>>6)+5],a[65];
int n,m,ans;
signed main(){
read(n),read(m);
for(int i=1,j;i<=m;++i){
read(j);
if(j>=64) for(int k=0;k<=n;k+=j) bs[k>>6]|=(1ull<<(k&63));
else{
for(int k=0;k<=64;++k) a[k]=0ull;
for(int k=0;k<=(j<<6);k+=j) a[k>>6]|=(1ull<<(k&63));
// for(int k=0;k<=(n>>6);k++) bs[k]|=a[k%j];
for(int k=0;k<=j;++k){
for(int q=k;q<=(n>>6);q+=j){
bs[q]|=a[k];
}
}
}
}
if((n&63)!=63) bs[n>>6]&=(1ull<<(n+1-((n>>6)<<6)))-1;
bs[0]&=-2ull;
for(int i=0;i<=(n>>6)+1;++i){
ans+=__builtin_popcountll(bs[i]&(bs[i]>>1)&(bs[i]>>2));
if((bs[i]&(1ull<<62))&&(bs[i]&(1ull<<63))&&(bs[i+1]&1)) ans++;
if((bs[i+1]&1)&&(bs[i]&(1ull<<63))&&(bs[i+1]&2)) ans++;
}
write(ans);
return 0;
}