#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e4 + 5;
int xr[MAX], yro[MAX], r[MAX];
int ro;
int dcmp(double x, double y) {
  return fabs(x - y) <= 1e-9 ? 0 : x < y ? -1 : 1;
};
int dist(int x1, int y1, int x2, int y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
bool solve(int x, int y) {
  for (int i = 0; i < ro; i++)
    if (dist(x, y, xr[i], yro[i]) <= r[i] * r[i]) return 0;
  return 1;
}
int main() {
  int x1, y1, x2, y2, ans = 0;
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> ro;
  for (int i = 0; i < (int)(ro); ++i) {
    cin >> xr[i] >> yro[i] >> r[i];
  }
  for (int i = min(x1, x2); i <= max(x1, x2); i++) {
    ans += solve(i, y1) + solve(i, y2);
  }
  for (int i = min(y1, y2) + 1; i < max(y1, y2); i++) {
    ans += solve(x1, i) + solve(x2, i);
  }
  cout << ans << '\n';
}
