#include <bits/stdc++.h>
using namespace std;
void Abdo() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
const long long int mod = 1e9;
long long int gcd(long long int a, long long int b) {
  return !b ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a / gcd(a, b)) * b;
}
long long int power(long long int x, long long int y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  long long int r = power(x, y / 2) % mod;
  return r % mod * r % mod * power(x, y % 2) % mod;
}
int dx[] = {1, 1, -1, -1};
int dy[] = {1, -1, -1, 1};
const long double EPS = 1e-9, PI = 3.141592653589793238462643383279502884;
const long long N = 1e3 + 4, M = 4e3 + 5, OO = 1LL << 60;
double dis(int x1, int y1, int x2, int y2) {
  return sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));
}
struct heater {
  int x, y, r;
};
int main(void) {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  set<pair<int, int> > mp;
  mp.insert({x1, y1});
  mp.insert({x2, y2});
  int l = min(x1, x2);
  int r = max(x1, x2);
  int u = max(y1, y2);
  int d = min(y1, y2);
  for (int i = l; i <= r; i++) mp.insert({i, u});
  for (int i = l; i <= r; i++) mp.insert({i, d});
  for (int i = d; i <= u; i++) mp.insert({l, i});
  for (int i = d; i <= u; i++) mp.insert({r, i});
  heater arr[N];
  int ans = 0, n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y, r;
    cin >> x >> y >> r;
    arr[i].x = x;
    arr[i].y = y;
    arr[i].r = r;
  }
  int cnt = 1;
  for (set<pair<int, int> >::iterator it = mp.begin(); it != mp.end(); ++it) {
    cnt = 1;
    for (int i = 0; i < n; i++) {
      if (dis(arr[i].x, arr[i].y, (*it).first, (*it).second) <= arr[i].r)
        cnt = 0;
    }
    if (cnt) ans++;
  }
  cout << ans;
}
