#include <bits/stdc++.h>
using namespace std;
bool COMP(pair<long, long> a, pair<long, long> b) {
  if (a.first != b.first) return a.first < b.first;
  return a.second < b.second;
}
long long int LOGINT(long long int value, long long int base) {
  long long int temp = 1, i;
  for (i = 1; temp < value; i++) {
    if (temp * base > value) break;
    temp = (temp * base);
  }
  return i - 1;
}
long long int POWER(long long int a, long long int n) {
  if (!n) return 1;
  if (n == 1) return a;
  long long int x = POWER(a, n / 2);
  return (n & 1) ? x * x * a : x * x;
}
int main() {
  ios::sync_with_stdio(false);
  long long int t, n, m, x1, x2, y1, y2, i, j, k, l, c = 0, loop1, loop2, tem;
  double r, res;
  cin >> x1 >> y1 >> x2 >> y2 >> t;
  vector<pair<long long int, long long int> > v;
  long long int arr[t + 15];
  for (i = 0; i < t; i++) {
    cin >> n >> m >> r;
    v.push_back({n, m});
    arr[i] = r;
  }
  if (x1 > x2)
    loop1 = x2, j = x1;
  else
    loop1 = x1, j = x2;
  if (y1 > y2)
    loop2 = y2, l = y1;
  else
    loop2 = y1, l = y2;
  for (i = loop1; i <= j; i++) {
    for (k = loop2; k <= l; k++) {
      bool flag = true;
      if (i == loop1 || i == j) {
        for (long long int pos = 0; pos < v.size(); pos++) {
          res = ((i - v[pos].first) * (i - v[pos].first)) +
                ((k - v[pos].second) * (k - v[pos].second));
          res = sqrt(res);
          if (res <= arr[pos]) {
            flag = false;
            break;
          }
        }
        if (flag) c++;
      } else if (k == loop2 || k == l) {
        for (long long int pos = 0; pos < v.size(); pos++) {
          res = ((i - v[pos].first) * (i - v[pos].first)) +
                ((k - v[pos].second) * (k - v[pos].second));
          res = sqrt(res);
          if (res <= arr[pos]) {
            flag = false;
            break;
          }
        }
        if (flag) c++;
      }
    }
  }
  cout << c << endl;
}
