#include <bits/stdc++.h>
using namespace std;
using ll = long long;
double euclideanDistance(int x1, int y1, int x2, int y2) {
  return sqrt(1.000 * (x2 - x1) * 1.000 * (x2 - x1) +
              1.000 * (y2 - y1) * 1.000 * (y2 - y1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  if (y1 > y2) {
    swap(y1, y2);
    swap(x1, x2);
  }
  int n;
  cin >> n;
  vector<pair<int, int>> gen;
  for (int i = y1; i <= y2; i++) {
    gen.emplace_back(make_pair(x1, i));
    gen.emplace_back(make_pair(x2, i));
  }
  for (int i = min(x1, x2) + 1; i <= max(x1, x2) - 1; i++) {
    gen.emplace_back(make_pair(i, y1));
    gen.emplace_back(make_pair(i, y2));
  }
  int blankets = 0;
  vector<int> rX(n), rY(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> rX[i] >> rY[i] >> r[i];
  }
  for (int i = 0; i < gen.size(); i++) {
    bool flag = 1;
    for (int j = 0; j < n; j++) {
      if (euclideanDistance(rX[j], rY[j], gen[i].first, gen[i].second) <=
          r[j]) {
        flag = 0;
        break;
      }
    }
    if (flag) blankets++;
  }
  cout << blankets;
  return 0;
}
