1 /**************************************************************
2 Problem: 1709
3 User: HansBug
4 Language: Pascal
5 Result: Accepted
6 Time:4 ms
7 Memory:304 kb
8 ****************************************************************/
9
10 var
11 i,j,k,l,m,n,x,y:longint;
12 a,b:array[0..100,0..100] of longint;
13 begin
14 readln(n,m);l:=0;
15 fillchar(a,sizeof(a),0);
16 fillchar(b,sizeof(b),0);
17 for i:=1 to m do
18 begin
19 readln(j,k);
20 l:=l+1-a[j,k];
21 a[j,k]:=1;
22 end;
23 m:=l;l:=0;
24 for i:=1 to n do
25 for j:=1 to n do
26 if a[i,j]=1 then
27 begin
28 x:=i-1;y:=j;
29 while x>0 do
30 begin
31 inc(b[x,y]);
32 dec(x);
33 end;
34 x:=i+1;y:=j;
35 while x<=n do
36 begin
37 inc(b[x,y]);
38 inc(x);
39 end;
40 x:=i;y:=j-1;
41 while y>0 do
42 begin
43 inc(b[x,y]);
44 dec(y);
45 end;
46 x:=i;y:=j+1;
47 while y<=n do
48 begin
49 inc(b[x,y]);
50 inc(y);
51 end;
52 x:=i-1;y:=j-1;
53 while (x>0) and (y>0) do
54 begin
55 inc(b[x,y]);
56 dec(x);dec(y);
57 end;
58 x:=i+1;y:=j-1;
59 while (x<=n) and (y>0) do
60 begin
61 inc(b[x,y]);
62 inc(x);dec(y);
63 end;
64 x:=i-1;y:=j+1;
65 while (x>0) and (y<=n) do
66 begin
67 inc(b[x,y]);
68 dec(x);inc(y);
69 end;
70 x:=i+1;y:=j+1;
71 while (x<=n) and (y<=n) do
72 begin
73 inc(b[x,y]);
74 inc(x);inc(y);
75 end;
76 inc(b[i,j]);
77 end;
78 l:=0;
79 for i:=1 to n do
80 for j:=1 to n do
81 if b[i,j]=m then inc(l);
82 writeln(l);
83 readln;
84 end.