#include <bits/stdc++.h>
using namespace std;
bool a[2010][2010];
int x[1000], y[1000], r[1000];
int main() {
  int x1, x2, y1, y2, i, j, k, ans = 0;
  cin >> x1 >> y1 >> x2 >> y2;
  if (x2 < x1) swap(x1, x2);
  if (y2 < y1) swap(y1, y2);
  int n;
  cin >> n;
  for (i = 0; i < n; i++) scanf("%d%d%d", &x[i], &y[i], &r[i]);
  for (i = x1; i <= x2; i++)
    for (j = y1; j <= y2; j += (i == x1 || i == x2 ? 1 : y2 - y1)) {
      for (k = 0; k < n; k++)
        if ((i - x[k]) * (i - x[k]) + (j - y[k]) * (j - y[k]) <= r[k] * r[k])
          break;
      if (k == n) ans++;
    }
  cout << ans << endl;
}
