#include <bits/stdc++.h>
using namespace std;
double dist(int x1, int x2, int y1, int y2) {
  double ans = ((double)(x1 - x2) * (double)(x1 - x2)) +
               ((double)(y1 - y2) * (double)(y1 - y2));
  ans = sqrt(ans);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int xa, ya, xb, yb, n;
  cin >> xa >> ya >> xb >> yb >> n;
  vector<pair<int, int>> v;
  pair<pair<int, int>, double> p[n];
  for (int i = 0; i < n; i++) {
    int x, y;
    double r;
    cin >> x >> y >> r;
    p[i].second = r;
    p[i].first.first = x;
    p[i].first.second = y;
  }
  for (int i = min(xa, xb); i <= max(xa, xb); i++) {
    for (int j = min(ya, yb); j <= max(ya, yb); j++) {
      if (i == min(xa, xb) || i == max(xa, xb) || j == min(ya, yb) ||
          j == max(ya, yb))
        v.push_back({i, j});
    }
  }
  int ans = 0;
  for (auto i : v) {
    int f = 0;
    for (auto j : p) {
      double d = dist(i.first, j.first.first, i.second, j.first.second);
      if (d <= j.second) {
        f = 1;
        break;
      }
    }
    if (f == 0) ans++;
  }
  cout << ans;
  return 0;
}
