#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1);
int dist(int x, int y, pair<int, int> a) {
  return (x - a.first) * (x - a.first) + (y - a.second) * (y - a.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int xa, ya, xb, yb;
  cin >> xa >> ya >> xb >> yb;
  int lx, ly, rx, ry;
  lx = min(xa, xb);
  rx = max(xa, xb);
  ly = min(ya, yb);
  ry = max(ya, yb);
  int n;
  cin >> n;
  vector<int> cost(n);
  vector<pair<int, int> > pos(n);
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    cost[i] = c;
    pos[i] = {a, b};
  }
  int numblank = 0;
  for (int x = lx; x < rx + 1; x++) {
    int y = ly;
    bool p = false;
    for (int i = 0; i < n; i++) {
      if (cost[i] * cost[i] >= dist(x, y, pos[i])) {
        p = true;
        break;
      }
    }
    if (!p) numblank++;
  }
  for (int x = lx; x < rx + 1; x++) {
    int y = ry;
    bool p = false;
    for (int i = 0; i < n; i++) {
      if (cost[i] * cost[i] >= dist(x, y, pos[i])) {
        p = true;
        break;
      }
    }
    if (!p) numblank++;
  }
  for (int y = ly + 1; y < ry; y++) {
    int x = lx;
    bool p = false;
    for (int i = 0; i < n; i++) {
      if (cost[i] * cost[i] >= dist(x, y, pos[i])) {
        p = true;
        break;
      }
    }
    if (!p) numblank++;
  }
  for (int y = ly + 1; y < ry; y++) {
    int x = rx;
    bool p = false;
    for (int i = 0; i < n; i++) {
      if (cost[i] * cost[i] >= dist(x, y, pos[i])) {
        p = true;
        break;
      }
    }
    if (!p) numblank++;
  }
  cout << numblank;
  cout.flush();
  return 0;
}
