#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d, x[1005], y[1005], r[1005], aa, bb, cc, dd;
int dis(int p, int q, int r, int s) {
  int u = (p - r) * (p - r) + (q - s) * (q - s);
  return u;
}
bool check(int a, int b) {
  bool f = false;
  for (int i = 0; i < n; i++) {
    int cc = x[i], dd = y[i];
    int y = dis(a, b, cc, dd);
    if (y <= r[i] * r[i]) {
      f = true;
      break;
    }
  }
  if (f)
    return true;
  else
    return false;
}
int main() {
  scanf("%d%d%d%d", &a, &b, &c, &d);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &x[i], &y[i], &r[i]);
  }
  int cnt = 0;
  aa = min(a, c);
  bb = max(a, c);
  cc = min(b, d);
  dd = max(b, d);
  for (int i = aa; i <= bb; i++) {
    if (check(i, cc)) cnt++;
    if (check(i, dd)) cnt++;
  }
  for (int i = cc + 1; i < dd; i++) {
    if (check(aa, i)) cnt++;
    if (check(bb, i)) cnt++;
  }
  int y = 2 * (bb - aa + 1) + 2 * (dd - cc - 1);
  printf("%d\n", y - cnt);
  return 0;
}
