#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define H(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(n); i++)
#define FE(i,n) for (int i=0; i<=(n); i++)
#define FX(i,a,b) for (int i=(a); i<(b); i++)
#define D(i,n) for (int i=(n); --i>=0;)
#define DX(i,a,b) for (int i=(b); --i>=(a);)
#define S(s) (int)((s).size())
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,(v))
#define MA(a,v) a = max(a,(v))
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
typedef complex<int> C;
#define x real()
#define y imag()
C r() {int a,b; cin>>a>>b; return {a,b};}
int cross(C a, C b) {return (conj(a)*b).y;}
int orient(C a, C b, C c) {return cross(b-a, c-a);}
struct ab {C a,b;};
// first true
/*template<class X> int lb(int n, X cmp) {
int l=-1, r=n;
//v[l] < elem, v[r] >= elem;
while (r-l >= 2)
(cmp((l+r)/2) ? r : l) = (l+r)/2;
return r;
}*/
// first false
template<class T, class X> T lb(T l, T r, X cmp) {
l--;
while (r-l >= 2) {
T mid = l+(r-l)/2;
(cmp(*mid) ? l : r) = mid;
}
return r;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n,m; cin>>n>>m;
V<C> ps(n);
F(i,n) ps[i]=r();
V<int> xs(n);
F(i,n) xs[i] = ps[i].x;
sort(ALL(xs));
xs.resize(unique(ALL(xs)) - xs.begin());
V<V<ab>> through(S(xs)), vert(S(xs));
//P("A");
F(i,n) {
C a=ps[i], b=ps[(i+1)%n];
if (a.x > b.x || (a.x == b.x && a.y > b.y))
swap(a,b);
int ia = lower_bound(ALL(xs), a.x) - xs.begin(),
ib = lower_bound(ALL(xs), b.x) - xs.begin();
FX(j,ia,ib)
through[j].pb({a,b});
if (ia == ib)
vert[ia].pb({a,b});
}
//P("B");
F(i,S(xs)) {
sort(ALL(through[i]), [](ab p, ab q) {
return orient(p.a, p.b, q.a) > 0 || orient(p.a, p.b, q.b) > 0;});
sort(ALL(vert[i]), [](ab p, ab q) {
return p.a.y < q.a.y;});
}
int tot=0;
F(qq,m) {
C a=r();
int j = upper_bound(ALL(xs), a.x) - xs.begin() - 1;
bool in=false;
if (j >= 0) {
//H(qq);
//H(j);
if (xs[j] == a.x) {
//P("test vert");
//for (ab p : vert[j]) cout<<p.a.y<<' '<<p.b.y<<endl;
auto it = lb(ALL(vert[j]), [&](ab p) {return p.b.y < a.y;});
//auto it = lower_bound(ALL(xs), ab{a,a}, [](ab p, ab q) {return p.b.y < q.b.y;});
if (it != vert[j].end() && it->a.y <= a.y && a.y <= it->b.y)
in = true;
}
auto it = lb(ALL(through[j]), [&](ab p) {return orient(p.a, p.b, a) > 0;});
if ((it - through[j].begin())%2 || (it != through[j].end() && orient(it->a, it->b, a) == 0))
in = true;
tot += in;
}
//H(in);
//P("");
}
cout<<tot<<"\n";
}