#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> x, y, r;
int pow2(int a) { return a * a; }
bool solve(int x1, int y1) {
  for (int i = 0; i < n; ++i) {
    if (pow2(x1 - x[i]) + pow2(y1 - y[i]) <= pow2(r[i])) return true;
  }
  return false;
}
int main() {
  int xa, ya, xb, yb;
  cin >> xa >> ya >> xb >> yb >> n;
  if (xa > xb) swap(xa, xb);
  if (ya > yb) swap(ya, yb);
  x = y = r = vector<int>(n);
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> r[i];
  int ret = 0;
  for (int i = xa; i <= xb; ++i) {
    if (!solve(i, ya)) ++ret;
    if (!solve(i, yb)) ++ret;
  }
  for (int i = ya + 1; i < yb; ++i) {
    if (!solve(xa, i)) ++ret;
    if (!solve(xb, i)) ++ret;
  }
  cout << ret << endl;
  return 0;
}
