#include <bits/stdc++.h>
using namespace std;
struct point {
  point() : flag(false) {}
  long long x, y;
  bool flag;
};
int main(int argc, char *argv[]) {
  long long xa, ya, xb, yb;
  int n;
  long long x[2000], y[2000], r[2000];
  cin >> xa >> ya >> xb >> yb >> n;
  for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> r[i];
  if (xa > xb) swap(xa, xb);
  if (ya > yb) swap(ya, yb);
  vector<point> points;
  for (int i = xa + 1; i < xb; i++) {
    point p;
    p.x = i;
    p.y = ya;
    points.push_back(p);
    p.y = yb;
    points.push_back(p);
  }
  for (int i = ya + 1; i < yb; i++) {
    point p;
    p.y = i;
    p.x = xa;
    points.push_back(p);
    p.x = xb;
    points.push_back(p);
  }
  {
    point p;
    p.x = xa, p.y = ya;
    points.push_back(p);
    p.x = xb, p.y = ya;
    points.push_back(p);
    p.x = xa, p.y = yb;
    points.push_back(p);
    p.x = xb, p.y = yb;
    points.push_back(p);
  }
  for (int i = 0; i < n; i++) {
    for (vector<point>::iterator it = points.begin(); it != points.end();
         it++) {
      if (((it->x - x[i]) * (it->x - x[i])) +
              ((it->y - y[i]) * (it->y - y[i])) <=
          ((r[i]) * (r[i]))) {
        it->flag = true;
      }
    }
  }
  int ret = 0;
  for (vector<point>::iterator it = points.begin(); it != points.end(); it++)
    if (!it->flag) ret++;
  cout << ret;
  return 0;
}
