#include <bits/stdc++.h>
using namespace std;
double xa, xb, ya, yb, ri[1001], x3[1001], y3[1001];
int rad, blankets, l;
bool e;
int main() {
  cin >> xa >> ya >> xb >> yb;
  cin >> rad;
  for (int i = 0; i < rad; i++) {
    cin >> x3[i] >> y3[i] >> ri[i];
  }
  for (int j = 0; j <= 1; j++) {
    if (j == 0)
      l = ya;
    else
      l = yb;
    for (int i = min(xa, xb); i <= max(xa, xb); i++) {
      for (int k = 0; k < rad; k++) {
        if (sqrt(pow(x3[k] - i, 2) + pow(y3[k] - l, 2)) <= ri[k]) {
          e = 0;
          break;
        } else
          e = 1;
      }
      if (e) {
        blankets++;
      }
      e = 0;
    }
  }
  for (int j = 0; j <= 1; j++) {
    if (j == 0)
      l = xa;
    else
      l = xb;
    for (int i = min(ya, yb) + 1; i < max(yb, ya); i++) {
      for (int k = 0; k < rad; k++) {
        if (sqrt(pow(x3[k] - l, 2) + pow(y3[k] - i, 2)) <= ri[k]) {
          e = 0;
          break;
        } else
          e = 1;
      }
      if (e) {
        blankets++;
      }
      e = 0;
    }
  }
  cout << blankets;
  return 0;
}
