#include <bits/stdc++.h>
using namespace std;
int x[1005], y[1005], r[1005];
int f(int xx, int yy, int i) {
  if ((x[i] - xx) * (x[i] - xx) + (y[i] - yy) * (y[i] - yy) <= r[i] * r[i])
    return 1;
  return 0;
}
int main() {
  int i, j, l, n, x0, y0, x1, y1, t1, t2, t3, t4;
  scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
  if (x0 > x1) swap(x0, x1);
  if (y0 > y1) swap(y0, y1);
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d%d%d", x + i, y + i, r + i);
  l = 0;
  for (i = x0; i <= x1; i++) {
    for (j = 0; j < n; j++)
      if (f(i, y0, j)) break;
    if (j == n) l++;
  }
  for (i = x0; i <= x1; i++) {
    for (j = 0; j < n; j++)
      if (f(i, y1, j)) break;
    if (j == n) l++;
  }
  for (i = y0; i <= y1; i++) {
    for (j = 0; j < n; j++)
      if (f(x0, i, j)) break;
    if (j == n) l++;
  }
  for (i = y0; i <= y1; i++) {
    for (j = 0; j < n; j++)
      if (f(x1, i, j)) break;
    if (j == n) l++;
  }
  t1 = t2 = t3 = t4 = 1;
  for (i = 0; i < n; i++) {
    if (f(x0, y0, i)) t1 = 0;
    if (f(x0, y1, i)) t2 = 0;
    if (f(x1, y0, i)) t3 = 0;
    if (f(x1, y1, i)) t4 = 0;
  }
  l -= t1 + t2 + t3 + t4;
  printf("%d\n", l);
  return 0;
}
