#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, center, p, q, r, s, n, sum, mini, maxi, res;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> a >> b >> c >> d;
  for (int i = 1; i <= n; i++) {
    center = i;
    p = 1;
    sum = a + b + p + center;
    q = sum - a - c - center;
    r = sum - b - d - center;
    s = sum - c - d - center;
    mini = min(min(min(p, q), r), s);
    if (mini < 1) {
      p += 1 - mini;
      q += 1 - mini;
      r += 1 - mini;
      s += 1 - mini;
    }
    maxi = max(max(max(p, q), r), s);
    if (maxi > n) {
      p -= maxi - n;
      q -= maxi - n;
      r -= maxi - n;
      s -= maxi - n;
    }
    maxi = max(max(max(p, q), r), s);
    mini = min(min(min(p, q), r), s);
    if (mini < 1 || maxi > n) continue;
    res += (mini + n - maxi);
  }
  cout << res;
}
