#include <bits/stdc++.h>
using namespace std;
int main() {
  int minx, miny, maxx, maxy;
  cin >> minx >> maxy >> maxx >> miny;
  int tmp;
  if (minx > maxx) {
    tmp = minx;
    minx = maxx;
    maxx = tmp;
  }
  if (miny > maxy) {
    tmp = miny;
    miny = maxy;
    maxy = tmp;
  }
  int n;
  cin >> n;
  int r[1010][3];
  for (int i = 0; i < n; i++) cin >> r[i][0] >> r[i][1] >> r[i][2];
  int cnt = 0;
  for (int i = minx; i <= maxx; i++) {
    bool flag = true;
    for (int j = 0; j < n; j++)
      if ((r[j][0] - i) * (r[j][0] - i) + (r[j][1] - miny) * (r[j][1] - miny) <=
          r[j][2] * r[j][2]) {
        flag = false;
        break;
      }
    if (flag) cnt++;
    flag = true;
    for (int j = 0; j < n; j++)
      if ((r[j][0] - i) * (r[j][0] - i) + (r[j][1] - maxy) * (r[j][1] - maxy) <=
          r[j][2] * r[j][2]) {
        flag = false;
        break;
      }
    if (flag) cnt++;
  }
  for (int i = miny + 1; i < maxy; i++) {
    bool flag = true;
    for (int j = 0; j < n; j++)
      if ((r[j][1] - i) * (r[j][1] - i) + (r[j][0] - minx) * (r[j][0] - minx) <=
          r[j][2] * r[j][2]) {
        flag = false;
        break;
      }
    if (flag) cnt++;
    flag = true;
    for (int j = 0; j < n; j++)
      if ((r[j][1] - i) * (r[j][1] - i) + (r[j][0] - maxx) * (r[j][0] - maxx) <=
          r[j][2] * r[j][2]) {
        flag = false;
        break;
      }
    if (flag) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
