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 namespace std;
class point {
 public:
  int x, y;
  void get() { cin >> x >> y; }
  void out() { cout << x << " " << y << "\n"; }
};
class ev {
 public:
  int x, y1, y2;
  bool window;
  ev(int X, int Y1, int Y2, bool WINDOW)
      : x(X), y1(Y1), y2(Y2), window(WINDOW) {}
};
bool cmp(ev& a, ev& b) {
  return (a.x == b.x ? a.window < b.window : a.x < b.x);
}
point v1, v2;
set<int> s;
void change(int x) {
  if (s.count(x))
    s.erase(x);
  else
    s.insert(x);
}
void inside(int& y) { y = min(max(y, v1.y), v2.y); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  v1.get(), v2.get();
  swap(v1.y, v2.y);
  int n;
  cin >> n;
  vector<point> v(n);
  for (int i = 0; i < n; i++) v[i].get();
  vector<ev> e;
  e.push_back(ev(v1.x, v1.y, v2.y, true));
  e.push_back(ev(v2.x, v1.y, v2.y, true));
  for (int i = 0; i < n; i++) {
    if (v[i].x != v[(i + 1) % n].x) continue;
    e.push_back(ev(v[i].x, v[i].y, v[(i + 1) % n].y, false));
  }
  sort(e.begin(), e.end(), cmp);
  int ans = 0;
  for (int i = 0; i < e.size(); i++) {
    if (e[i].window) {
      if (e[i].x == v1.x)
        ans = s.size() / 2;
      else
        break;
      continue;
    }
    if (max(e[i].y1, e[i].y2) <= v1.y || min(e[i].y1, e[i].y2) >= v2.y)
      continue;
    int pv = s.size() / 2;
    inside(e[i].y1), inside(e[i].y2);
    change(e[i].y1), change(e[i].y2);
    if (v1.x <= e[i].x && e[i].x < v2.x && e[i].y2 < e[i].y1) {
      if (s.size() / 2 < pv) ans--;
      if (s.size() / 2 > pv) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}