#include <bits/stdc++.h>
int pct(int x) { return __builtin_popcount(x); }
using namespace std;
ifstream fin("0.in");
ofstream fout("ans.out");
bool dist(pair<int, int> coords, vector<int>& d, bool swit) {
  if (swit) {
    int temp = coords.first;
    coords.first = coords.second;
    coords.second = temp;
  }
  if ((coords.first - d[0]) * (coords.first - d[0]) +
          (coords.second - d[1]) * (coords.second - d[1]) <=
      d[2] * d[2])
    return true;
  return false;
}
int ans = 0;
void row(int xa, int xb, int j, vector<vector<int>>& rad, bool swit) {
  for (int i = xa; i <= xb; i++) {
    bool good = false;
    for (auto r : rad) {
      if (dist({i, j}, r, swit)) {
        good = true;
        break;
      }
    }
    if (!good) {
      ans++;
    }
  }
}
int main() {
  int xa, ya, xb, yb;
  cin >> xa >> ya >> xb >> yb;
  int n;
  cin >> n;
  int x, y, r;
  vector<vector<int>> rad;
  while (n--) {
    cin >> x >> y >> r;
    rad.push_back({x, y, r});
  }
  if (ya > yb) {
    int temp = yb;
    yb = ya;
    ya = temp;
  }
  if (xa > xb) {
    int temp = xb;
    xb = xa;
    xa = temp;
  }
  row(xa + 1, xb - 1, ya, rad, false);
  row(xa + 1, xb - 1, yb, rad, false);
  row(ya, yb, xa, rad, true);
  row(ya, yb, xb, rad, true);
  cout << ans << endl;
  return 0;
}
