#include <bits/stdc++.h>   using namespace std;   const long long N = 1e3 + 10;   const long long M = 1e9 + 7;   long long Max(long long a, long long b) {     if (a > b) return a;     return b;   }   long long Min(long long a, long long b) {     if (a > b) return b;     return a;   }   long long big_mul(long long a, long long b, long long m) {     long long x = 0, y = a % m;     while (b > 0) {       if (b & 1) x = (x + y) % m;       y = (2 * y) % m;       b >>= 1;     }     return x % m;   }   long long big_mod(long long a, long long b, long long m) {     long long x = 1, y = a % m;     while (b > 0) {       if (b & 1) x = (x * y) % m;       y = (y * y) % m;       b >>= 1;     }     return x % m;   }   long long Big_mod(long long a, long long b, long long m) {     long long x = 1, y = a % m;     while (b > 0) {       if (b & 1) x = big_mul(x, y, m);       y = big_mul(y, y, m);       b >>= 1;     }     return x % m;   }   long long mod_inverse(long long a, long long m) { return big_mod(a, m - 2, m); }   unordered_map<string, bool> Map;   int a, b, c, d, e, f, g, h;   vector<pair<int, int> > vec;   vector<pair<pair<int, int>, int> > save;   void fnct(int x1, int y1, int x2, int y2) {     if (x1 < x2 && y1 > y2) {       a = x1;       b = y2;       c = x1;       d = y1;       e = x2;       f = y1;       g = x2;       h = y2;     } else if (x1 > x2 && y1 < y2) {       a = x2;       b = y1;       c = x2;       d = y2;       e = x1;       f = y2;       g = x1;       h = y1;     } else if (x1 < x2 && y1 < y2) {       a = x1;       b = y1;       c = x1;       d = y2;       e = x2;       f = y2;       g = x2;       h = y1;     } else {       a = x2;       b = y2;       c = x2;       d = y1;       e = x1;       f = y1;       g = x1;       h = y2;     }   }   double dis(double w, double z, double p, double q) {     double n = w - p;     double m = z - q;     return sqrt(n * n + m * m);   }   bool check(double p, double q) {     for (int i = 0; i < save.size(); i++) {       double w = (double)(save[i].first.first);       double z = (double)(save[i].first.second);       double r = (double)(save[i].second);       if (dis(w, z, p, q) <= r) return true;     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int x1, y1, x2, y2;     cin >> x1 >> y1 >> x2 >> y2;     fnct(x1, y1, x2, y2);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int w, z, r;       cin >> w >> z >> r;       if (Map[to_string(w) + to_string(z) + to_string(r)] == false)         save.push_back(make_pair(make_pair(w, z), r));       Map[to_string(w) + to_string(z) + to_string(r)] = true;     }     for (int i = c; i <= e; i++) vec.push_back(make_pair(i, d));     for (int i = a; i <= g; i++) vec.push_back(make_pair(i, b));     for (int i = d - 1; i > b; i--) vec.push_back(make_pair(a, i));     for (int i = f - 1; i > h; i--) vec.push_back(make_pair(e, i));     int ans = 0;     for (int i = 0; i < vec.size(); i++) {       double p = (double)(vec[i].first);       double q = (double)(vec[i].second);       if (check(p, q) == false) ans++;     }     cout << ans << endl;     return 0;   }   