#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <fstream>
#include <bitset>
#include <iomanip>
using namespace std;
#pragma GCC optimize("O2")
// #pragma GCC optimize("O1","O2","O3","Ofast","unroll-loops")
// #pragma GCC target("sse","sse2","sse3","sse4.1","sse4.2","avx","avx2")
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
/*
notes:
int64_t
stoi(string s) -> string to int
to_string() -> int (or else) to string
vector declaration:
vector<ll> v(n, 0)
vector<vector<ll>> v(n, vector<ll>(n, 0));
{if statement} ? {truth value} : {false value}
set lower bound/upper bound:
// . . . m1 . . . d . . . . m2
auto m1_it = b.lower_bound(d);
advance(m1_it, -1);
m1 = *m1_it;
m2 = *b.upper_bound(d);
#ifdef LOCAL
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
constexpr auto lcm(auto x, auto... xs)
{
return ((x = std::lcm(x, xs)), ...);
}
std::gcd(int a, int b)
cout << setprecision(n);
*/
typedef long long ll;
ll angle(double a, double b, double c) {
// we get the cosine of the angle FACING side 'a'
// changed: a is actually a distance squared
if(a == b + c) {
return 90;
}
if(a > b + c) {
return 100;
}else{
return 50;
}
/*
if(a * a == b * b + c * c) {
return 90;
}
if(a * a > b * b + c * c) {
return 100;
}else{
return 50;
}
*/
double cosine = (b * b + c * c - a * a) / (2 * b * c);
//cerr << "\na=" << a;
//cerr << "\nb=" << b;
//cerr << "\nc=" << c;
//cerr << "\ncos=" << cosine;
if(cosine == 0 || cosine == 1 || cosine == -1) {
return 90;
}
if(cosine < 0) {
return 100;
}else{
return 50;
}
}
double dis(pair<ll,ll> a, pair<ll,ll> b) {
double x = abs(b.first - a.first);
double y = abs(b.second - a.second);
//return sqrtl(x * x + y * y);
return x * x + y * y;
}
void solve() {
pair<ll,ll> tl;
pair<ll,ll> tr;
pair<ll,ll> br;
pair<ll,ll> bl; // bottomleft
cin >> tl.first >> tl.second;
cin >> tr.first >> tr.second;
cin >> br.first >> br.second;
cin >> bl.first >> bl.second;
ll n;
cin >> n;
vector<pair<ll,ll>> v(n, {0,0});
for(ll i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
}
ll sum = 0;
/*
if(dis(bl, tl) == 0 || dis(tl, tr) == 0) {
cout << "0";
return;
}
*/
for(ll i = 0; i < n; i++) {
double a1, a2, a3, c1, c2, c3, b3, d3;
a1 = dis(tl, v[i]);
a2 = dis(tr, v[i]);
a3 = dis(tl, tr);
c1 = dis(v[i], br);
c2 = dis(v[i], bl);
c3 = dis(bl, br);
b3 = dis(tr, br);
d3 = dis(tl, bl);
vector<ll> angles;
ll anga = 0;
ll angb = 0;
ll angc = 0;
ll angd = 0;
anga = max(anga, angle(a3, a1, a2));
//anga = max(anga, angle(a2, a1, a3));
//anga = max(anga, angle(a1, a2, a3));
angb = max(angb, angle(b3, c1, a2));
//angb = max(angb, angle(c1, a2, b3));
//angb = max(angb, angle(a2, c1, b3));
angc = max(angc, angle(c3, c1, c2));
//angc = max(angc, angle(c1, c3, c2));
//angc = max(angc, angle(c2, c1, c3));
angd = max(angd, angle(d3, c2, a1));
//angd = max(angd, angle(c2, d3, a1));
//angd = max(angd, angle(a1, c2, d3));
angles.push_back(anga);
angles.push_back(angb);
angles.push_back(angc);
angles.push_back(angd);
sort(angles.begin(), angles.end());
//cerr << "\nangles=" << angles;
if(angles[0] == 50 && angles[1] == 50 && angles[2] == 100 && angles[3] == 100) {
sum++;
}
}
cout << sum;
}
int main()
{
std::ios_base::sync_with_stdio(false);
//cin.tie(nullptr);
//cout.tie(nullptr);
solve();
return 0;
}