#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
FILE *f=fopen("poligon.in","r");
FILE *g=fopen("poligon.out","w");
pair<double,double> P[805];
vector<double> bands;
vector<pair<pair<double,double>,pair<double,double> > > V[805];
vector<int> pula[805];
int N,M,rez;
bool cmp(pair<pair<double,double>,pair<double,double> > a,pair<pair<double,double>,pair<double,double> > b)
{
return a.first.second+a.second.second<b.first.second+b.second.second;
}
double det(pair<double,double> a,pair<double,double> b,pair<double,double> c)
{
return a.first*b.second-a.first*c.second+b.first*c.second-b.first*a.second+c.first*a.second-c.first*b.second;
}
const int LEN=10000;
int ind=LEN-1;
char buff[LEN];
int i32()
{
int rez=0,sgn=1;
while((buff[ind]<'0'||buff[ind]>'9')&&buff[ind]!='-')
{
if(++ind>=LEN)
{
ind=0;
fread(buff,1,LEN,f);
}
}
if(buff[ind]=='-')
{
sgn=-1;
if(++ind>=LEN)
{
ind=0;
fread(buff,1,LEN,f);
}
}
while(buff[ind]>='0'&&buff[ind]<='9')
{
rez=rez*10+buff[ind]-'0';
if(++ind>=LEN)
{
ind=0;
fread(buff,1,LEN,f);
}
}
return rez*sgn;
}
int main()
{
N=i32();M=i32();
for(int i=1;i<=N;i++)
{
P[i].first=i32();P[i].second=i32();
bands.push_back(P[i].first);
}
sort(bands.begin(),bands.end());
bands.resize(distance(bands.begin(),unique(bands.begin(),bands.end())));
for(int i=1;i<=N;i++)
{
pair<int,int> P1=P[i],P2=P[i%N+1];
if(P1.first==P2.first){pula[P1.first].push_back(P1.second);pula[P2.first].push_back(P2.second);}
}
for(int i=1;i<=N;i++)sort(pula[(int)P[i].first].begin(),pula[(int)P[i].first].end());
for(int i=0;i<bands.size()-1;i++)
{
double x1=bands[i],x2=bands[i+1];
for(int j=1;j<=N;j++)
{
pair<double,double> P1=P[j],P2=P[j%N+1];
if(P1>P2)swap(P1,P2);
if(P1.first<=x1&&x2<=P2.first)
{
double A=P2.second-P1.second,B=P1.first-P2.first,C=1LL*P1.second*P2.first-1LL*P1.first*P2.second;
double y1=(-C-A*x1)/B;
double y2=(-C-A*x2)/B;
V[i].push_back({{x1,y1},{x2,y2}});
}
}
V[i].push_back({{-100,-100},{-100,-100}});
sort(V[i].begin(),V[i].end(),cmp);
}
double xmin=bands[0],xmax=bands.back();
for(int i=1;i<=M;i++)
{
double x,y;
x=i32();y=i32();
if(x<xmin||x>xmax)continue;
if(!pula[(int)x].empty())
{
if(distance(pula[(int)x].begin(),lower_bound(pula[(int)x].begin(),pula[(int)x].end(),y))&1){rez++;continue;}
}
int ind,st=0,dr=bands.size()-2;
while(st<dr)
{
int mid=(st+dr+1)/2;
if(bands[mid]<=x)st=mid;
else dr=mid-1;
}
ind=st;
st=0;dr=V[ind].size()-1;
while(st<dr)
{
int mid=(st+dr+1)/2;
if(det(V[ind][mid].first,V[ind][mid].second,{x,y})==0){st=1;break;}
else if(det(V[ind][mid].first,V[ind][mid].second,{x,y})>0){st=mid;}
else dr=mid-1;
}
rez+=(st&1);
/// printf("%d %d\n",i,st&1);
}
fprintf(g,"%d\n",rez);
fclose(f);
fclose(g);
return 0;
}
/*
*/