#include <bits/stdc++.h>
using namespace std;
int xa, xb, ya, yb, n;
struct radiator {
  int x;
  int y;
  int r;
} R[1005];
int dist(int x, int y, int xx, int yy) {
  return ((x - xx) * (x - xx) + (y - yy) * (y - yy));
}
int main() {
  cin >> xa >> ya >> xb >> yb;
  if (xa > xb) {
    int tmp = xa;
    xa = xb;
    xb = tmp;
  }
  if (ya > yb) {
    int tmp = ya;
    ya = yb;
    yb = tmp;
  }
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> R[i].x >> R[i].y >> R[i].r;
  }
  int SOL = 0;
  for (int i = xa; i <= xb; ++i) {
    int x = i, y = ya;
    bool ok = false;
    for (int j = 1; j <= n; ++j)
      if (dist(x, y, R[j].x, R[j].y) <= R[j].r * R[j].r) {
        ok = true;
        break;
      }
    if (!ok) ++SOL;
    ok = false;
    x = i, y = yb;
    for (int j = 1; j <= n; ++j)
      if (dist(x, y, R[j].x, R[j].y) <= R[j].r * R[j].r) {
        ok = true;
        break;
      }
    if (!ok) ++SOL;
  }
  for (int i = ya + 1; i <= yb - 1; ++i) {
    int x = xa, y = i;
    bool ok = false;
    for (int j = 1; j <= n; ++j)
      if (dist(x, y, R[j].x, R[j].y) <= R[j].r * R[j].r) {
        ok = true;
        break;
      }
    if (!ok) ++SOL;
    x = xb, y = i;
    ok = false;
    for (int j = 1; j <= n; ++j)
      if (dist(x, y, R[j].x, R[j].y) <= R[j].r * R[j].r) {
        ok = true;
        break;
      }
    if (!ok) ++SOL;
  }
  cout << SOL;
  return 0;
}
