#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("poligon.in");
ofstream fout("poligon.out");
struct punct
{
int x, y;
} p[60005], varf[805];
struct latura
{
punct a, b, mn, mx;
long long dx, dy;
} L[805];
int n, m, nr = 0;
bool cmp(latura a, latura b)
{
return a.mx.x < b.mx.x;
}
void precalculare()
{
for (int i = 1; i <= n; i++)
{
punct a = varf[i - 1];
punct b = varf[i];
if (a.y > b.y)
swap(a, b);
L[i].a = a;
L[i].b = b;
L[i].mn.x = min(a.x, b.x);
L[i].mx.x = max(a.x, b.x);
L[i].mn.y = a.y;
L[i].mx.y = b.y;
L[i].dx = 1LL * b.x - a.x;
L[i].dy = 1LL * b.y - a.y;
}
sort(L + 1, L + n + 1, cmp);
}
int cautare_binara(int val)
{
int i, step;
for (step = 1; step <= n / 2; step <<= 1)
;
for (i = 0; step; step >>= 1)
{
if (i + step <= n && L[i + step].mx.x < val)
i += step;
}
return i + 1;
}
int solve()
{
for (int i = 1; i <= m; i++)
{
int cnt = 0;
int x = p[i].x;
int y = p[i].y;
int poz = cautare_binara(x);
for (int j = poz; j <= n; j++)
{
if (y < L[j].mn.y || y > L[j].mx.y)
continue;
if (x < L[j].mn.x)
{
if (y < L[j].mx.y)
cnt++;
continue;
}
long long det = L[j].dx * (1LL * y - L[j].a.y) -
L[j].dy * (1LL * x - L[j].a.x);
if (det == 0)
{
cnt = 1;
break;
}
if (y < L[j].mx.y && det > 0)
cnt++;
}
if (cnt % 2 == 1)
nr++;
}
return nr;
}
int main()
{
fin >> n >> m;
for (int i = 1; i <= n; i++)
fin >> varf[i].x >> varf[i].y;
varf[0] = varf[n];
precalculare();
for (int i = 1; i <= m; i++)
fin >> p[i].x >> p[i].y;
fout << solve();
return 0;
}