function dist(x1,x2,y1,y2:integer):real;
begin
exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));
end;
procedure Make;
var
i,j:integer;
begin
for i:=1 to n-1 do
for j:=1 to m do
if dist(a[i,1],b[j,1],a[i,2],b[j,2])+dist(a[i+1,1],b[j,1],a[i+1,2],b[j,2])<=
2*dist(a[i,1],a[i+1,1],a[i,2],a[i+1,2]) then
g[i,j]:=true;
end;
function Find(k:integer):boolean;
var
i:integer;
begin
for i:=1 to m do
if (Not sy[i]) and (g[k,i]) then
begin
sy[i]:=true;
if (cy[i]=0) or (Find(cy[i])) then
begin
cy[i]:=k;
cx[k]:=i;
exit(true);
end;
end;
exit(false);
end;
procedure Km;
var
i,tot:integer;
begin
tot:=1;
fillchar(cx,sizeof(cx),0);
fillchar(cy,sizeof(cy),0);
for i:=1 to n-1 do
begin
fillchar(sy,sizeof(sy),0);
if Find(i) then inc(tot,2) else
inc(tot);
end;
writeln(tot);
end;
begin
assign(input,'dog.in'); reset(input);
assign(output,'dog.out'); rewrite(output);
init;
Make;
Km;
close(input); close(output);
end.
Program Dog_Maxflow_Mpq;
type data=record
limit:integer;
flow:integer;
end;
Const Maxn=100;
var
n,m,s,t,Answer:integer;
queue:array[1..Maxn*2+1] of integer;
v:array[1..Maxn*2+1] of integer;
a,b:array[1..Maxn,1..2] of integer;
g:array[1..Maxn*2+1,1..Maxn*2+1] of data;
function dist(x1,x2,y1,y2:integer):real;
begin
exit(sqrt(sqr(x1-x2)+sqr(y1-y2)));
end;
procedure init;
var
i,j:integer;
begin
readln(n,m);
for i:=1 to n do read(a[i,1],a[i,2]);
readln;
for j:=1 to m do read(b[j,1],b[j,2]);
readln;
fillchar(g,sizeof(g),0);
for i:=1 to n-1 do
g[1,i+1].limit:=1;
for i:=1 to n-1 do
for j:=1 to m do
if dist(a[i,1],b[j,1],a[i,2],b[j,2])+dist(a[i+1,1],b[j,1],a[i+1,2],b[j,2])<=
2*dist(a[i,1],a[i+1,1],a[i,2],a[i+1,2]) then
g[i+1,j+n].limit:=1;
for i:=1 to m do
g[i+n,n+m+1].limit:=1;
end;
function Mins(a,b:integer):integer;
begin
if a>b then exit(b) else exit(a);
end;
procedure MaxFlow;
var
i,j,Min,head,last:integer;
begin
Answer:=n;
s:=1; t:=n+m+1;
while true do
begin
fillchar(v,sizeof(v),0);
head:=1; last:=1;
v[1]:=s;
queue[1]:=1;
repeat
if head<=last then i:=queue[head] else break;
for j:=1 to t do
if v[j]=0 then
if g[i,j].flow<g[i,j].limit then
begin
inc(last);
queue[last]:=j;
v[j]:=i;
end else
if g[j,i].flow>0 then
begin
inc(last);
queue[last]:=j;
v[j]:=-i;
end;
inc(head);
until v[t]<>0;
if v[t]=0 then break;
Min:=Maxint;
i:=t;
while i<>s do
begin
if v[i]>0 then Min:=Mins(g[v[i],i].limit-g[v[i],i].flow,Min) else
Min:=Mins(g[i,abs(v[i])].flow,Min);
i:=abs(v[i]);
end;
i:=t;
inc(Answer,Min);
while i<>s do
begin
if v[i]>0 then inc(g[v[i],i].flow,Min) else
dec(g[i,abs(v[i])].flow,Min);
i:=abs(v[i]);
end;
end;
writeln(Answer);
end;
begin
assign(input,'dog.in'); reset(input);
assign(output,'dog.out'); rewrite(output);
init;
Maxflow;
close(input); close(output);
end.