#include <bits/stdc++.h>
using namespace std;
double distance(int x0, int y0, int x1, int y1) {
  return (double)sqrt(((x0 - x1) * (x0 - x1)) + ((y0 - y1) * (y0 - y1)));
}
int main() {
  int x0, y0, x1, y1;
  scanf("%d%d%d%d", &x0, &y0, &x1, &y1);
  int start_x = min(x0, x1);
  int end_x = max(x0, x1);
  int start_y = min(y0, y1);
  int end_y = max(y0, y1);
  set<pair<int, int>> points;
  int saber = start_x;
  while (saber <= end_x) {
    points.insert({saber, start_y});
    points.insert({saber, end_y});
    saber++;
  }
  saber = start_y;
  while (saber <= end_y) {
    points.insert({start_x, saber});
    points.insert({end_x, saber});
    saber++;
  }
  int n;
  scanf("%d", &n);
  int ans = 0;
  vector<pair<pair<int, int>, int>> v(n);
  for (int i = 0; i < n; i++) {
    int one, two, r;
    scanf("%d%d%d", &one, &two, &r);
    v[i] = {{one, two}, r};
  }
  for (auto general : points) {
    bool ok = false;
    for (auto heater : v) {
      if (distance(general.first, general.second, heater.first.first,
                   heater.first.second) <= heater.second) {
        ok = true;
        break;
      }
    }
    ans += !ok;
  }
  printf("%d\n", ans);
}
