#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1, x2, y1, y2;
  int n, m;
  int x[1100], y[1100], r[1100];
  int a, b, c, d;
  cin >> a >> c >> b >> d;
  x1 = min(a, b);
  x2 = max(a, b);
  y1 = min(c, d);
  y2 = max(c, d);
  cin >> n;
  int ans = 0, bb;
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> r[i];
  for (int xx = x1; xx <= x2; xx++)
    for (int yy = y1; yy <= y2; yy++)
      if (xx == x1 || xx == x2 || yy == y1 || yy == y2) {
        bb = 0;
        for (int i = 0; i < n; i++)
          if (r[i] * r[i] >=
              (x[i] - xx) * (x[i] - xx) + (y[i] - yy) * (y[i] - yy)) {
            bb = 1;
            break;
          }
        if (bb == 0) {
          ans++;
        }
      }
  cout << ans;
  return 0;
}
