#include <bits/stdc++.h>
using namespace std;
int main() {
  int xa, ya, xb, yb;
  cin >> xa >> ya >> xb >> yb;
  int q;
  cin >> q;
  int x[q], y[q], r[q];
  for (int i = 0; i < q; i++) {
    cin >> x[i] >> y[i] >> r[i];
  }
  int ans = 0;
  for (int i = min(xa, xb); i <= max(xa, xb); i++) {
    int f = 0;
    for (int j = 0; j < q; j++) {
      if ((((i - x[j]) * (i - x[j])) + ((ya - y[j]) * (ya - y[j]))) <=
          (r[j] * r[j])) {
        f = 1;
        break;
      }
    }
    if (f == 0) ans++;
  }
  for (int i = min(xa, xb); i <= max(xa, xb); i++) {
    int f = 0;
    for (int j = 0; j < q; j++) {
      if ((((i - x[j]) * (i - x[j])) + ((yb - y[j]) * (yb - y[j]))) <=
          (r[j] * r[j])) {
        f = 1;
        break;
      }
    }
    if (f == 0) ans++;
  }
  for (int i = min(ya, yb) + 1; i < max(yb, ya); i++) {
    int f = 0;
    for (int j = 0; j < q; j++) {
      if ((((xa - x[j]) * (xa - x[j])) + ((i - y[j]) * (i - y[j]))) <=
          (r[j] * r[j])) {
        f = 1;
        break;
      }
    }
    if (f == 0) ans++;
  }
  for (int i = min(ya, yb) + 1; i < max(ya, yb); i++) {
    int f = 0;
    for (int j = 0; j < q; j++) {
      if ((((xb - x[j]) * (xb - x[j])) + ((i - y[j]) * (i - y[j]))) <=
          (r[j] * r[j])) {
        f = 1;
        break;
      }
    }
    if (f == 0) ans++;
  }
  cout << ans;
}
