#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 + 1;
struct Point {
  int x, y;
  double r;
} P[MAXN];
int xa, ya, xb, yb;
int n;
bool DIS(int x, int y) {
  for (int i = 0; i < n; i++) {
    double dis =
        ((x - P[i].x) * (x - P[i].x) + (y - P[i].y) * (y - P[i].y)) * 1.0;
    if (dis <= P[i].r * P[i].r) return false;
  }
  return true;
}
bool run() {
  if (scanf("%d%d%d%d", &xa, &ya, &xb, &yb) == EOF) return false;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%lf", &P[i].x, &P[i].y, &P[i].r);
  }
  int ans = 0;
  int MinX = min(xa, xb);
  int MaxX = max(xa, xb);
  int MinY = min(ya, yb);
  int MaxY = max(ya, yb);
  for (int i = MinX; i <= MaxX; i++) {
    if (DIS(i, MinY)) ans++;
  }
  for (int i = MinX; i <= MaxX; i++) {
    if (DIS(i, MaxY)) ans++;
  }
  for (int i = MinY + 1; i < MaxY; i++) {
    if (DIS(MinX, i)) ans++;
  }
  for (int i = MinY + 1; i < MaxY; i++) {
    if (DIS(MaxX, i)) ans++;
  }
  printf("%d\n", ans);
  return true;
}
int main() {
  while (run())
    ;
  return 0;
}
