#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const double eps = 1e-6;
const int maxn = 1e6 + 10, base = 1e9 + 7;
const int sigm = 26;
const long long llinf = 1e18;
void bad(string mes = "Impossible") {
  cout << mes;
  exit(0);
}
template <typename T>
string bin(T x) {
  string ans = "";
  while (x > 0) {
    ans += char('0' + x % 2);
    x /= 2;
  }
  reverse(ans.begin(), ans.end());
  return ans.empty() ? "0" : ans;
}
template <typename T>
T dcm(string& second) {
  T x = 0;
  for (int i = 0; i < second.size(); i++) {
    x = (x * 2) + (second[i] == '1');
  }
  return x;
}
template <typename T>
T input() {
  T ans = 0, m = 1;
  char c = ' ';
  while (c == ' ' || c == '\n') c = getchar();
  if (c == '-') m = -1, c = getchar();
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + int(c - '0'), c = getchar();
  }
  return ans * m;
}
template <typename T>
T binpow(T n, T second) {
  if (second == 0) return 1LL;
  if (second % 2 == 0) {
    T b = binpow(n, second / 2) % base;
    return (1LL * b * b) % base;
  } else {
    return (1LL * binpow(n, second - 1) * n) % base;
  }
}
int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long ans = 0;
  for (int e = 1; e <= n; e++) {
    int k[4] = {0};
    k[0] = e + b + d;
    k[1] = e + c + d;
    k[2] = e + a + c;
    k[3] = e + a + b;
    int mn = inf, mx = -inf;
    for (int j = 0; j < 4; j++) {
      mn = min(mn, k[j]);
      mx = max(mx, k[j]);
    }
    mn += n;
    mx += 1;
    if (mn >= mx) ans += (long long)mn - mx + 1;
  }
  cout << ans;
}
