#include <bits/stdc++.h>
using namespace std;
const int ZERO = 1005;
int n, x, y, r, xx, yy;
int xa, xb, ya, yb;
int a[2100][2100];
int main() {
  scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
  if (xa > xb) swap(xa, xb);
  if (ya > yb) swap(ya, yb);
  scanf("%d", &n);
  memset(a, 0, sizeof a);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &xx, &yy, &r);
    for (int x = xa; x <= xb; x++) {
      if (((x - xx) * (x - xx)) + ((ya - yy) * (ya - yy)) <= ((r) * (r)))
        a[ZERO + x][ZERO + ya] = 1;
      if (((x - xx) * (x - xx)) + ((yb - yy) * (yb - yy)) <= ((r) * (r)))
        a[ZERO + x][ZERO + yb] = 1;
    }
    for (int y = ya; y <= yb; y++) {
      if (((xa - xx) * (xa - xx)) + ((y - yy) * (y - yy)) <= ((r) * (r)))
        a[ZERO + xa][ZERO + y] = 1;
      if (((xb - xx) * (xb - xx)) + ((y - yy) * (y - yy)) <= ((r) * (r)))
        a[ZERO + xb][ZERO + y] = 1;
    }
  }
  int ans = 0;
  for (int x = xa; x <= xb; x++)
    for (int y = ya; y <= yb; y++)
      if (x == xa || x == xb || y == ya || y == yb)
        if (a[ZERO + x][ZERO + y] == 0) ans++;
  printf("%d\n", ans);
  return 0;
}
