1 #include<cstdio>
2 #include<iostream>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #define maxn 1000006
7 using namespace std;
8 char ch;
9 int m,n,ans,a[maxn],b[maxn],idx,tmp;
10 bool ok;
11 void read(int &x){
12 for (ok=0,ch=getchar();!isdigit(ch);ch=getchar()) if (ch==‘-‘) ok=1;
13 for (x=0;isdigit(ch);x=x*10+ch-‘0‘,ch=getchar());
14 if (ok) x=-x;
15 }
16 int main(){
17 read(m),read(n);
18 for (int i=1;i<=n;i++) read(a[i]);
19 if (a[n]==m-1){
20 ans=1;
21 for (int i=n-1;i>=1&&a[i+1]-a[i]==1;i--) ans++;
22 printf("%d\n",ans);
23 return 0;
24 }
25 a[n+1]=m-1;
26 for (int i=n;i>=1;i--)
27 if (a[i+1]-a[i]==1) b[idx]++;
28 else if (a[i+1]-a[i]==2) b[++idx]=1;
29 else if ((a[i+1]-a[i]-1)&1) idx+=3,b[idx]=1;
30 else idx+=2,b[idx]=1;
31 for (int i=1;i<=idx;i+=2) tmp^=b[i];
32 if (tmp){
33 for (int i=1;i<=idx;i+=2) if ((b[i]^tmp)<b[i]) ans++;
34 for (int i=2;i<=idx;i+=2) if ((tmp^b[i-1])>b[i-1]&&(b[i-1]^tmp)<=b[i]+b[i-1]) ans++;
35 printf("%d\n",ans);
36 }
37 else puts("0");
38 return 0;
39 }