#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  vector<pair<int, int>> vec;
  int xmin = min(x1, x2);
  int xmax = max(x1, x2);
  int ymin = min(y1, y2);
  int ymax = max(y1, y2);
  for (int i = ymin; i <= ymax; ++i) vec.push_back(make_pair(xmin, i));
  for (int i = ymin; i <= ymax; ++i) vec.push_back(make_pair(xmax, i));
  for (int i = xmin + 1; i < xmax; ++i) vec.push_back(make_pair(i, ymin));
  for (int i = xmin + 1; i < xmax; ++i) vec.push_back(make_pair(i, ymax));
  int size = vec.size();
  vector<int> cond(size);
  int t;
  cin >> t;
  for (int j = 0; j < t; ++j) {
    int x, y, r;
    cin >> x >> y >> r;
    for (int i = 0; i < size; ++i)
      if ((long long)(x - vec[i].first) * (x - vec[i].first) +
              (y - vec[i].second) * (y - vec[i].second) <=
          r * r)
        cond[i] = 1;
  }
  long long c = 0;
  for (int i = 0; i < size; ++i)
    if (cond[i] == 0) ++c;
  cout << c << endl;
}
