#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 1e8 + 5;
const long long mod = 1e9 + 7;
const double pi = 3.1415926536;
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
int xa, ya, xb, yb, n;
vector<pair<int, int> > v;
vector<int> r;
int sqr(int a) { return a * a; }
int dist(int xa, int ya, int xb, int yb) { return sqr(xa - xb) + sqr(ya - yb); }
bool check(int x, int y) {
  for (int i = 0; i < n; i++)
    if (dist(v[i].first, v[i].second, x, y) <= sqr(r[i])) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  ;
  cin >> xa >> ya >> xb >> yb >> n;
  if (xa > xb) swap(xa, xb);
  if (ya > yb) swap(ya, yb);
  for (int i = 0; i < n; i++) {
    int x, y, r1;
    cin >> x >> y >> r1;
    v.push_back({x, y});
    r.push_back(r1);
  }
  int cnt = 0;
  for (int x = xa; x <= xb; x++) {
    if (!check(x, ya)) cnt++;
    if (!check(x, yb)) cnt++;
  }
  for (int y = ya + 1; y <= yb - 1; y++) {
    if (!check(xa, y)) cnt++;
    if (!check(xb, y)) cnt++;
  }
  cout << cnt;
  return 0;
}
