#include <bits/stdc++.h>
using namespace std;
struct node {
  int first;
  int second;
  int r;
};
bool dist(int first, int second, node& a) {
  int d = (first - a.first) * (first - a.first) +
          (second - a.second) * (second - a.second);
  return d <= a.r * a.r;
}
void solve() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int n;
  cin >> n;
  vector<node> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second >> a[i].r;
  }
  int ans = 0;
  int nx = min(x1, x2), mx = max(x1, x2);
  int ny = min(y1, y2), my = max(y1, y2);
  for (int first = nx; first <= mx; ++first) {
    vector<int> v;
    if (first == nx || first == mx) {
      v.resize(my - ny + 1);
      iota(v.begin(), v.end(), ny);
    } else {
      v.push_back(ny);
      v.push_back(my);
    }
    for (auto second : v) {
      bool ok = 0;
      for (int k = 0; k < n; ++k) {
        if (dist(first, second, a[k])) {
          ok = 1;
          break;
        }
      };
      if (!ok) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
