#include <bits/stdc++.h>
using namespace std;
void setIO(string s = "") {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin.exceptions(cin.failbit);
  if (s.size()) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
  }
}
long long int M[10005];
void solve() {
  long long int n, m, j, k, l, i;
  long long int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  vector<pair<long long int, long long int>> v;
  for (i = min(x1, x2); i <= max(x1, x2); i++) {
    j = y1;
    v.push_back(make_pair(i, j));
  }
  for (i = min(x1, x2); i <= max(x1, x2); i++) {
    j = y2;
    v.push_back(make_pair(i, j));
  }
  for (j = min(y1, y2) + 1; j < max(y1, y2); j++) {
    i = x2;
    v.push_back(make_pair(i, j));
  }
  for (j = min(y1, y2) + 1; j < max(y1, y2); j++) {
    i = x1;
    v.push_back(make_pair(i, j));
  }
  long long int ans = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    long long int x, y, r;
    cin >> x >> y >> r;
    for (long long int j = 0; j < v.size(); j++) {
      if ((v[j].first - x) * (v[j].first - x) +
              (v[j].second - y) * (v[j].second - y) <=
          r * r) {
        M[j] = 1;
      }
    }
  }
  for (long long int i = 0; i < v.size(); i++) {
    if (M[i] == 0) {
      ans++;
    }
  }
  cout << ans;
  cout << "\n";
  return;
}
int main() {
  setIO();
  long long int totalTestCase = 1;
  for (long long int testCase = 1; testCase <= totalTestCase; testCase++) {
    solve();
  }
  return 0;
}
