#include <bits/stdc++.h>
using namespace std;
int dist(int x1, int y1, int x2, int y2) {
  return (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
}
int main() {
  int x1, x2, y1, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  int n, num;
  vector<pair<pair<int, int>, bool> > g;
  if (x1 > x2) x1 ^= x2, x2 ^= x1, x1 ^= x2;
  if (y1 > y2) y1 ^= y2, y2 ^= y1, y1 ^= y2;
  for (int i = x1; i <= x2; i++) {
    g.push_back(make_pair(make_pair(i, y1), 0));
    g.push_back(make_pair(make_pair(i, y2), 0));
  }
  for (int i = y1 + 1; i < y2; i++) {
    g.push_back(make_pair(make_pair(x1, i), 0));
    g.push_back(make_pair(make_pair(x2, i), 0));
  }
  num = g.size();
  scanf("%d", &n);
  int ans = 0, x, y, r;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &x, &y, &r);
    for (int j = 0; j < num; j++) {
      if (g[j].second == 0 &&
          dist(x, y, g[j].first.first, g[j].first.second) <= r * r) {
        g[j].second = 1;
        ans++;
      }
    }
  }
  printf("%d\n", num - ans);
  return 0;
}
