#include <bits/stdc++.h>
using namespace std;
int cnt, n, xa, xb, ya, yb, x[1500], y[1500], r[1500];
bool check(int xx, int yy) {
  for (int k = 0; k < n; ++k)
    if (((xx - x[k]) * (xx - x[k]) + (yy - y[k]) * (yy - y[k])) <=
        (r[k] * r[k]))
      return 1;
  return 0;
}
int main() {
  cin >> xa >> ya >> xb >> yb >> n;
  if (xa > xb) swap(xa, xb);
  if (ya > yb) swap(ya, yb);
  for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> r[i];
  for (int i = xa; i <= xb; ++i)
    if (!check(i, ya)) cnt++;
  for (int i = xa; i <= xb; ++i)
    if (!check(i, yb)) cnt++;
  for (int i = ya + 1; i < yb; ++i)
    if (!check(xa, i)) cnt++;
  for (int i = ya + 1; i < yb; ++i)
    if (!check(xb, i)) cnt++;
  cout << cnt;
}
