#include <bits/stdc++.h>
const int INF = (int)1e9;
using namespace std;
const int MAX = 1e3 + 5;
int n, xa, ya, xb, yb;
pair<pair<int, int>, int> arr[MAX];
vector<pair<int, int> > vec;
bool covered(int x1, int y1, int x2, int y2, int R) {
  double dist = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  return dist <= (double)R;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> xa >> ya >> xb >> yb >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
  }
  if (xa > xb) swap(xa, xb);
  if (ya > yb) swap(ya, yb);
  for (int i = ya; i <= yb; i++) {
    vec.push_back(make_pair(xa, i));
    vec.push_back(make_pair(xb, i));
  }
  for (int i = xa + 1; i < xb; i++) {
    vec.push_back(make_pair(i, ya));
    vec.push_back(make_pair(i, yb));
  }
  int res = 0;
  for (int i = 0; i < vec.size(); i++) {
    bool flag = false;
    for (int j = 0; j < n; j++) {
      if (covered(vec[i].first, vec[i].second, arr[j].first.first,
                  arr[j].first.second, arr[j].second)) {
        flag = true;
        break;
      }
    }
    if (!flag) res++;
  }
  cout << res << '\n';
  return 0;
}
