#include <bits/stdc++.h>
using namespace std;
const int oo = 2000000000;
const int maxn = 755;
long long n, a, b, c, d, ans;
inline int read() {
  int x = 0;
  bool flag = false;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') flag = true;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return flag ? -x : x;
}
int main() {
  cin >> n >> a >> b >> c >> d;
  for (int i = 1; i <= n; i++) {
    long long a1 = a + b + i, a2 = a + c + i;
    long long a3 = b + d + i, a4 = d + c + i;
    long long maxx = max(a1, max(a2, max(a3, a4)));
    long long sum = maxx + 1;
    long long dif1 = sum - a1, dif2 = sum - a2, dif3 = sum - a3,
              dif4 = sum - a4;
    long long res = min(n - dif1, min(n - dif2, min(n - dif3, n - dif4))) + 1;
    if (res > 0) ans += res;
  }
  cout << ans << endl;
  return 0;
}
