#include <bits/stdc++.h>
using namespace std;
int main() {
  long long ans = 0, n;
  cin >> n;
  while (n--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    ans += (fabs(c - a) + 1) * (1 + fabs(d - b));
  }
  cout << ans << endl;
}
