#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int xa, ya, xb, yb, n;
  cin >> xa >> ya >> xb >> yb >> n;
  vector<int> X(n), Y(n), R(n);
  for (int i = 0; i < n; ++i) cin >> X[i] >> Y[i] >> R[i];
  if (xa > xb) swap(xa, xb);
  if (ya > yb) swap(ya, yb);
  int ans = 0;
  for (int i = xa; i <= xb; i++) {
    bool flag = false;
    for (int j = 0; j < n; ++j) {
      int d = (X[j] - i) * (X[j] - i) + (Y[j] - ya) * (Y[j] - ya);
      if (d <= R[j] * R[j]) flag = true;
    }
    ans += !flag;
    flag = false;
    for (int j = 0; j < n; ++j) {
      int d = (X[j] - i) * (X[j] - i) + (Y[j] - yb) * (Y[j] - yb);
      if (d <= R[j] * R[j]) flag = true;
    }
    ans += !flag;
  }
  for (int i = ya + 1; i < yb; ++i) {
    bool flag = false;
    for (int j = 0; j < n; ++j) {
      int d = (X[j] - xa) * (X[j] - xa) + (Y[j] - i) * (Y[j] - i);
      if (d <= R[j] * R[j]) flag = true;
    }
    ans += !flag;
    flag = false;
    for (int j = 0; j < n; ++j) {
      int d = (X[j] - xb) * (X[j] - xb) + (Y[j] - i) * (Y[j] - i);
      if (d <= R[j] * R[j]) flag = true;
    }
    ans += !flag;
  }
  cout << ans << "\n";
  return 0;
}
