#include <bits/stdc++.h>
using namespace std;
class data {
 public:
  long long x, y, r;
  data(long long a, long long b, long long c) { x = a, y = b, r = c; }
};
int main() {
  long long xa, ya, xb, yb;
  cin >> xa >> ya >> xb >> yb;
  long long n;
  cin >> n;
  vector<data> all;
  while (n--) {
    long long a, b, r;
    cin >> a >> b >> r;
    all.push_back(data(a, b, r));
  }
  long long xmin = min(xa, xb);
  long long xmax = max(xa, xb);
  long long ymin = min(ya, yb);
  long long ymax = max(ya, yb);
  vector<data> possible;
  for (long long i = xmin; i <= xmax; i++) {
    possible.push_back(data(i, ymin, 0));
    possible.push_back(data(i, ymax, 0));
  }
  for (long long i = ymin + 1; i < ymax; i++) {
    possible.push_back(data(xmax, i, 0));
    possible.push_back(data(xmin, i, 0));
  }
  long long pp = possible.size();
  long long kk = all.size();
  long long c = 0;
  for (long long i = 0; i < pp; i++) {
    data curg = possible[i];
    long long flag = 0;
    for (long long j = 0; j < kk; j++) {
      data lamp = all[j];
      long long dist = ((lamp.x - curg.x) * (lamp.x - curg.x)) +
                       ((lamp.y - curg.y) * (lamp.y - curg.y));
      long long rr = lamp.r * lamp.r;
      if (dist <= ((lamp.r) * (lamp.r))) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      c++;
    }
  }
  cout << c << "\n";
  return 0;
}
