#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const int N = 2 * 1e5 + 10;
ll res;
ll a[N];
std::set<pair<ll, ll>> s;
std::vector<pair<ll, ll>> v;
void solve() {
  ll x, y, xx, yy, n, rr;
  cin >> x >> y >> xx >> yy >> n;
  for (int i = min(x, xx); i <= max(x, xx); ++i) {
    s.insert({i, min(y, yy)});
    s.insert({i, max(y, yy)});
  }
  for (int i = min(y, yy); i <= max(y, yy); ++i) {
    s.insert({min(x, xx), i});
    s.insert({max(x, xx), i});
  }
  for (int i = 0; i < n; ++i) {
    cin >> xx >> yy >> rr;
    for (auto j : s) {
      x = j.first, y = j.second;
      if ((x - xx) * (x - xx) + (y - yy) * (y - yy) <= rr * rr) {
        v.push_back({x, y});
      }
    }
    for (auto j : v) {
      s.erase({j.first, j.second});
    }
  }
  cout << s.size();
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t = 1;
  while (t--) {
    solve();
  }
}
