#include <bits/stdc++.h>
using namespace std;
int xa, xb, ya, yb, n, r[1100], x[1100], y[1100], a[2100][2100], t, u, v;
int main() {
  scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
  xa += 1000;
  xb += 1000;
  ya += 1000;
  yb += 1000;
  if (xa > xb) {
    t = xa;
    xa = xb;
    xb = t;
  }
  if (ya > yb) {
    t = ya;
    ya = yb;
    yb = t;
  }
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &x[i], &y[i], &r[i]);
    x[i] += 1000;
    y[i] += 1000;
    for (int j = xa; j <= xb; j++)
      if (abs(j - x[i]) <= r[i]) {
        t = (int)floor(sqrt(r[i] * r[i] - (x[i] - j) * (x[i] - j)) + y[i]);
        u = (int)ceil(y[i] - sqrt(r[i] * r[i] - (x[i] - j) * (x[i] - j)));
        a[j][max(0, u)]++;
        a[j][min(2001, t + 1)]--;
      }
  }
  u = 0;
  for (int i = xa; i <= xb; i++) {
    t = 0;
    for (int j = 0; j <= 2000; j++) {
      t += a[i][j];
      if (j >= ya && j <= yb && t > 0) {
        if (i == xa || i == xb)
          u++;
        else if (j == ya || j == yb)
          u++;
      }
    }
  }
  printf("%d\n", (xb - xa + yb - ya) * 2 - u);
  return 0;
}
