#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:20000000")
using namespace std;
int ri() {
  int x;
  scanf("%d", &x);
  return x;
}
long long rll() {
  long long x;
  scanf("%lld", &x);
  return x;
}
void solve() {
  int LX, LY, RX, RY;
  cin >> LX >> LY >> RX >> RY;
  if (LX > RX) swap(LX, RX);
  if (LY > RY) swap(LY, RY);
  set<pair<int, int> > st;
  for (int i = (int)(LX); i <= (int)(RX); i++) {
    st.insert(make_pair(i, LY));
    st.insert(make_pair(i, RY));
  }
  for (int j = (int)(LY); j <= (int)(RY); j++) {
    st.insert(make_pair(LX, j));
    st.insert(make_pair(RX, j));
  }
  int n = ri();
  for (int i = (int)(1); i <= (int)(n); i++) {
    int x = ri(), y = ri(), r = ri();
    set<pair<int, int> >::iterator it, it1;
    for (it = st.begin(); it != st.end();) {
      int xx = it->first;
      int yy = it->second;
      if ((xx - x) * (xx - x) + (yy - y) * (yy - y) <= r * r) {
        it1 = it;
        it1++;
        st.erase(it);
        it = it1;
      } else
        it++;
    }
  }
  cout << st.size() << endl;
}
int main() {
  solve();
  return 0;
}
