#include <bits/stdc++.h>
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
const int inf = 1e8;
int dir[4][2] = {0, -1, -1, 0, 0, 1, 1, 0};
const int MAX = 100000;
const int MAXN = 30;
using namespace std;
struct vote {
  int a;
  char name[20];
};
bool comp(vote x, vote y) { return x.a > y.a; }
int main() {
  int x[1000];
  int y[1000];
  int r[1000];
  int n, i;
  int xa, ya, xb, yb;
  scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d%d%d", &x[i], &y[i], &r[i]);
  }
  int xmin = min(xa, xb);
  int xmax = max(xa, xb);
  int ymin = min(ya, yb);
  int ymax = max(ya, yb);
  int k, j;
  int sum = 0;
  for (k = ymin; k <= ymax; k++) {
    for (j = xmin; j <= xmax; j++) {
      if (k == ymin || k == ymax || j == xmin || j == xmax) {
        for (i = 1; i <= n; i++) {
          if (sqrt((j - x[i]) * (j - x[i]) + (k - y[i]) * (k - y[i])) <= r[i]) {
            break;
          } else if (i == n) {
            sum++;
          }
        }
      }
    }
  }
  printf("%d\n", sum);
  return 0;
}
