#include <bits/stdc++.h>
struct lu {
  int x;
  int y;
  double r;
} stove[1005];
double distence(int x1, int y1, int x2, int y2) {
  return sqrt((double)((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));
}
int main() {
  int xa, ya, xb, yb;
  while (scanf("%d%d%d%d", &xa, &ya, &xb, &yb) != EOF) {
    int n;
    int count = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
      scanf("%d%d%lf", &stove[i].x, &stove[i].y, &stove[i].r);
    if (xa > xb) {
      int t = xa;
      xa = xb;
      xb = t;
    }
    if (ya > yb) {
      int t = ya;
      ya = yb;
      yb = t;
    }
    for (int i = xa; i <= xb; i++) {
      int can = 0;
      for (int j = 1; j <= n; j++) {
        if (distence(stove[j].x, stove[j].y, i, ya) <= stove[j].r) {
          can = 1;
          break;
        }
      }
      if (!can) count++;
      can = 0;
      for (int j = 1; j <= n; j++) {
        if (distence(stove[j].x, stove[j].y, i, yb) <= stove[j].r) {
          can = 1;
          break;
        }
      }
      if (!can) count++;
    }
    for (int i = ya + 1; i < yb; i++) {
      int can = 0;
      for (int j = 1; j <= n; j++) {
        if (distence(stove[j].x, stove[j].y, xa, i) <= stove[j].r) {
          can = 1;
          break;
        }
      }
      if (!can) count++;
      can = 0;
      for (int j = 1; j <= n; j++) {
        if (distence(stove[j].x, stove[j].y, xb, i) <= stove[j].r) {
          can = 1;
          break;
        }
      }
      if (!can) count++;
    }
    printf("%d\n", count);
  }
}
