#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > pt;
int x[1000];
int y[1000];
int r[1000];
int main() {
  int xa, xb, ya, yb;
  cin >> xa;
  cin >> ya;
  cin >> xb;
  cin >> yb;
  if (xa > xb) swap(xa, xb);
  if (ya > yb) swap(ya, yb);
  for (int xx = xa; xx <= xb; xx++) {
    pt.push_back(pair<int, int>(xx, ya));
    pt.push_back(pair<int, int>(xx, yb));
  }
  for (int yy = ya + 1; yy < yb; yy++) {
    pt.push_back(pair<int, int>(xa, yy));
    pt.push_back(pair<int, int>(xb, yy));
  }
  int n;
  cin >> n;
  for (int j = 0; j < n; j++) {
    cin >> x[j];
    cin >> y[j];
    cin >> r[j];
  }
  int ans = 0;
  int s = pt.size();
  for (int i = 0; i < s; i++) {
    int xx = pt[i].first;
    int yy = pt[i].second;
    bool ok = false;
    for (int j = 0; j < n; j++) {
      int dx = xx - x[j];
      int dy = yy - y[j];
      int d = dx * dx + dy * dy;
      if (d <= r[j] * r[j]) ok = true;
    }
    if (!ok) ans++;
  }
  cout << ans << endl;
  return 0;
}
