#include <bits/stdc++.h>
using namespace std;
int a[1010][1010];
int main() {
  int xa, xb, ya, yb;
  int n;
  int i, j;
  int x[1010], y[1010], r[1010];
  int s, jg;
  int t;
  cin >> xa >> ya >> xb >> yb;
  cin >> n;
  if (xa > xb) {
    t = xa;
    xa = xb;
    xb = t;
  }
  if (ya < yb) {
    t = ya;
    ya = yb;
    yb = t;
  }
  for (i = 1; i <= n; i++) cin >> x[i] >> y[i] >> r[i];
  s = 0;
  for (i = ya; i >= yb; i--) {
    jg = 0;
    for (j = 1; j <= n; j++)
      if (sqrt((x[j] - xa) * (x[j] - xa) + (y[j] - i) * (y[j] - i)) <= r[j])
        jg = jg + 1;
    if (jg == 0) s = s + 1;
  }
  for (i = yb; i <= ya; i++) {
    jg = 0;
    for (j = 1; j <= n; j++)
      if (sqrt((x[j] - xb) * (x[j] - xb) + (y[j] - i) * (y[j] - i)) <= r[j])
        jg = jg + 1;
    if (jg == 0) s = s + 1;
  }
  for (i = xa + 1; i <= xb - 1; i++) {
    jg = 0;
    for (j = 1; j <= n; j++)
      if (sqrt((x[j] - i) * (x[j] - i) + (y[j] - ya) * (y[j] - ya)) <= r[j])
        jg = jg + 1;
    if (jg == 0) s = s + 1;
  }
  for (i = xa + 1; i <= xb - 1; i++) {
    jg = 0;
    for (j = 1; j <= n; j++)
      if (sqrt((x[j] - i) * (x[j] - i) + (y[j] - yb) * (y[j] - yb)) <= r[j])
        jg = jg + 1;
    if (jg == 0) s = s + 1;
  }
  cout << s << endl;
  return 0;
}
