#include <bits/stdc++.h>
using namespace std;
int n;
struct circle {
  int r;
  int x, y;
} C[1005];
int mk[2500][2500];
int judge(int i, int j, circle t) {
  int l = t.x - i, r = t.y - j;
  if (l * l + r * r <= t.r * t.r) return 1;
  return 0;
}
int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  if (a > c) swap(a, c);
  if (b > d) swap(b, d);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d%d", &C[i].x, &C[i].y, &C[i].r);
  int s = 0;
  for (int i = a; i <= c; i++) {
    for (int j = b; j <= d; j++) {
      if (i != a && i != c && j != b && j != d) continue;
      int t = 0;
      for (int k = 0; k < n; k++) {
        if (judge(i, j, C[k])) t = 1;
      }
      if (t == 0) {
        s++;
      }
    }
  }
  printf("%d\n", s);
}
