#include <bits/stdc++.h>
using namespace std;
struct rad {
  int x;
  int y;
  int r;
};
int main() {
  vector<pair<int, int> > points;
  vector<rad> radiat;
  int x1, y1, x3, y3, x2, y2, x4, y4;
  int tx1, ty1, tx2, ty2;
  cin >> tx1 >> ty1 >> tx2 >> ty2;
  x1 = min(tx1, tx2);
  x2 = min(tx1, tx2);
  x3 = max(tx1, tx2);
  x4 = max(tx1, tx2);
  y1 = max(ty1, ty2);
  y2 = min(ty1, ty2);
  y3 = min(ty1, ty2);
  y4 = max(ty1, ty2);
  int n;
  int c = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    rad x;
    cin >> x.x >> x.y >> x.r;
    radiat.push_back(x);
  }
  for (int i = y1; i > y2; i--) points.push_back(make_pair(x1, i));
  for (int i = x2; i < x3; i++) points.push_back(make_pair(i, y2));
  for (int i = y3; i < y4; i++) points.push_back(make_pair(x3, i));
  for (int i = x4; i > x1; i--) points.push_back(make_pair(i, y1));
  int ans = points.size();
  for (int i = 0; i < points.size(); i++)
    for (int j = 0; j < radiat.size(); j++) {
      int x_1, x_2, y_1, y_2, _r;
      x_1 = points[i].first;
      y_1 = points[i].second;
      x_2 = radiat[j].x;
      y_2 = radiat[j].y;
      _r = radiat[j].r;
      if (_r * _r >= (x_1 - x_2) * (x_1 - x_2) + (y_1 - y_2) * (y_1 - y_2)) {
        ans--;
        break;
      }
    }
  cout << ans;
  return 0;
}
