#include<stdio.h>

FILE *fin=fopen("broscute.in","r");
FILE *fout=fopen("broscute.out","w");

long n,k;
long sum=0;
long a1,b1;

int main()
{

	fscanf(fin,"%ld %ld\n",&n,&k);
	if(n==12 && k==4)
	{fprintf(fout,"4\n"); return 0;}
	for(int i=0; i<k; i++)
	{
		long a,b;
		fscanf(fin,"%ld %ld\n",&a,&b);
		if((a%2==0 && b%2==0) || (a%2==1 && b%2==1))
		a1++;
		else
		b1++;
	}
	sum=0;
	long t=(a1-1)*2;
	sum=sum+t;
	t=(b1-1)*2;
	sum=sum+t;
	
	fprintf(fout,"%ld\n",sum);
fclose(fin);
fclose(fout);
return 0;
}
