#include <bits/stdc++.h>
using namespace std;
const int maxn = 1001;
int n, xa, xb, ya, yb;
int x[maxn], y[maxn], r[maxn];
void enter() {
  scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &x[i], &y[i], &r[i]);
}
int check(int a, int b) {
  for (int i = 1; i <= n; i++) {
    if ((a - x[i]) * (a - x[i]) + (b - y[i]) * (b - y[i]) <= r[i] * r[i])
      return 0;
  }
  return 1;
}
void solve() {
  int res = 0;
  for (int i = min(xa, xb); i <= max(xa, xb); i++)
    res += check(i, ya) + check(i, yb);
  for (int i = min(ya, yb) + 1; i < max(ya, yb); i++)
    res += check(xa, i) + check(xb, i);
  printf("%d\n", res);
}
int main() {
  enter();
  solve();
  return 0;
}
