#include <bits/stdc++.h>
using namespace std;
int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int sq(int n) { return n * n; }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int xa, xb, ya, yb, t, n;
  cin >> xa >> ya >> xb >> yb;
  int temp;
  if (xa > xb) {
    temp = xa;
    xa = xb;
    xb = temp;
  }
  if (ya > yb) {
    temp = ya;
    ya = yb;
    yb = temp;
  }
  cin >> n;
  int h[n][3];
  for (int i = 0; i < n; i++) {
    cin >> h[i][0];
    cin >> h[i][1];
    cin >> h[i][2];
    h[i][2] *= h[i][2];
  }
  int i, j, num = 0, count = 0;
  for (i = xa; i <= xb; i++) {
    for (j = 0; j < n; j++)
      if (sq(h[j][0] - i) + sq(h[j][1] - ya) <= h[j][2]) break;
    if (j == n) num++;
  }
  for (i = xa; i <= xb; i++) {
    for (j = 0; j < n; j++)
      if (sq(h[j][0] - i) + sq(h[j][1] - yb) <= h[j][2]) break;
    if (j == n) num++;
  }
  if (ya == yb) num /= 2;
  for (i = ya + 1; i < yb; i++) {
    for (j = 0; j < n; j++)
      if (sq(h[j][0] - xa) + sq(h[j][1] - i) <= h[j][2]) break;
    if (j == n) count++;
  }
  for (i = ya + 1; i < yb; i++) {
    for (j = 0; j < n; j++)
      if (sq(h[j][0] - xb) + sq(h[j][1] - i) <= h[j][2]) break;
    if (j == n) count++;
  }
  if (xa == xb) count /= 2;
  cout << count + num;
  return 0;
}
