Problem: Petya has a polygon consisting of n vertices. All sides of the Petya's polygon are parallel to the coordinate axes, and each two adjacent sides of the Petya's polygon are perpendicular. It is guaranteed that the polygon is simple, that is, it doesn't have self-intersections and self-touches. All internal area of the polygon (borders are not included) was painted in black color by Petya.

Also, Petya has a rectangular window, defined by its coordinates, through which he looks at the polygon. A rectangular window can not be moved. The sides of the rectangular window are parallel to the coordinate axes.

<image> Blue color represents the border of a polygon, red color is the Petya's window. The answer in this case is 2.

Determine the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.

Input

The first line contain four integers x_1, y_1, x_2, y_2 (x_1 < x_2, y_2 < y_1) — the coordinates of top-left and bottom-right corners of the rectangular window. 

The second line contains a single integer n (4 ≤ n ≤ 15 000) — the number of vertices in Petya's polygon.

Each of the following n lines contains two integers — the coordinates of vertices of the Petya's polygon in counterclockwise order. Guaranteed, that the given polygon satisfies the conditions described in the statement.

All coordinates of the rectangular window and all coordinates of the vertices of the polygon are non-negative and do not exceed 15 000.

Output

Print the number of black connected areas of Petya's polygon, which can be seen through the rectangular window.

Example

Input

5 7 16 3
16
0 0
18 0
18 6
16 6
16 1
10 1
10 4
7 4
7 2
2 2
2 6
12 6
12 12
10 12
10 8
0 8


Output

2

Note

The example corresponds to the picture above.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using std::make_pair;
const int MAXN = 15000 + 10;
int low, high, left, right;
int n;
std::pair<int, int> p[MAXN];
namespace solver1 {
std::vector<std::pair<int, int> > v[MAXN];
std::set<std::pair<std::pair<int, int>, int> > seg;
int ans = 0;
namespace dsu {
int fa[MAXN << 1], cnt;
void init() { cnt = 0; }
int nxt() {
  ++cnt;
  fa[cnt] = cnt;
  return cnt;
}
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
bool unite(int u, int v) {
  u = find(u), v = find(v);
  if (u == v) return 0;
  fa[u] = v;
  return 1;
}
}  // namespace dsu
void work(int y, std::pair<int, int> line) {
  auto it = seg.upper_bound({{line.first, MAXN}, MAXN});
  if (it != seg.begin() && std::prev(it)->first.second >= line.second) {
    --it;
    if (it->first.first < line.first) {
      seg.insert({{it->first.first, line.first - 1}, it->second});
    }
    if (line.second < it->first.second) {
      seg.insert({{line.second + 1, it->first.second}, it->second});
    }
    seg.erase(it);
  } else {
    std::pair<std::pair<int, int>, int> cur = {line, dsu::nxt()};
    ans++;
    if (it != seg.begin() && std::prev(it)->first.second + 1 == line.first) {
      auto t = std::prev(it);
      cur.first.first = t->first.first;
      ans -= dsu::unite(t->second, cur.second);
      seg.erase(t);
    }
    if (it != seg.end() && line.second + 1 == it->first.first) {
      cur.first.second = it->first.second;
      ans -= dsu::unite(it->second, cur.second);
      seg.erase(it);
    }
    seg.insert(cur);
  }
}
void main() {
  p[n + 1] = p[1];
  for (int i = 1; i <= n; i++) {
    if (p[i].second == p[i + 1].second) {
      int l = std::min(p[i].first, p[i + 1].first);
      l = std::max(l, left);
      int r = std::max(p[i].first, p[i + 1].first);
      r = std::min(r, right);
      if (l < r) v[p[i].second].push_back(make_pair(l, r - 1));
    }
  }
  for (int i = 0; i < high; i++) {
    for (auto x : v[i]) {
      work(i, x);
    }
    if (i == low) {
      ans = 0;
      dsu::init();
      std::set<std::pair<std::pair<int, int>, int> > tmp;
      for (auto x : seg) {
        tmp.insert({x.first, dsu::nxt()});
        ans++;
      }
      seg = tmp;
    }
  }
  printf("%d\n", ans);
}
}  // namespace solver1
int main() {
  scanf("%d%d%d%d", &left, &high, &right, &low);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &p[i].first, &p[i].second);
  }
  solver1::main();
}