#include <bits/stdc++.h>
using namespace std;
set<pair<long long int, long long int> > general;
struct radiator {
  long long int x, y, r;
} arr[1005];
int main() {
  long long int xa, ya, xb, yb, n, xc, yc, xd, yd;
  cin >> xa >> ya >> xb >> yb;
  xc = xa, yc = yb, xd = xb, yd = ya;
  long long int fixed = xa, minm = min(yc, ya), maxm = max(yc, ya);
  for (long long int i = minm; i < maxm + 1; i++) {
    general.insert({fixed, i});
  }
  fixed = ya, minm = min(xa, xd), maxm = max(xa, xd);
  for (long long int i = minm; i < maxm + 1; i++) {
    general.insert({i, fixed});
  }
  fixed = xd, minm = min(yd, yb), maxm = max(yd, yb);
  for (long long int i = minm; i < maxm + 1; i++) {
    general.insert({fixed, i});
  }
  fixed = yb, minm = min(xc, xb), maxm = max(xc, xb);
  for (long long int i = minm; i < maxm + 1; i++) {
    general.insert({i, fixed});
  }
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i].x >> arr[i].y >> arr[i].r;
  }
  long long int cnt = 0, flag;
  for (auto itr = general.begin(); itr != general.end(); itr++) {
    pair<long long int, long long int> val = *itr;
    flag = 0;
    for (long long int i = 0; i < n; i++) {
      long double dist =
          sqrt((arr[i].x - val.first) * (arr[i].x - val.first) +
               (arr[i].y - val.second) * (arr[i].y - val.second));
      if (dist <= arr[i].r) {
        flag = 1;
        break;
      }
    }
    if (!flag) cnt++;
  }
  cout << cnt << endl;
}
