#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
const double eps = 1e-9;
int ts, kk = 1;
long long int a, b, c, d, n;
long long int gr[3][3];
int main() {
  int t, i, j, k;
  cin >> n >> a >> b >> c >> d;
  long long int rs = 0;
  for (i = 1; i <= n; i++) {
    long long int lo, hi;
    lo = max(a + b + i + 1, d + b + i + 1);
    hi = min(a + b + i + n, d + b + i + n);
    if (lo > hi) continue;
    lo = max(lo, a + i + c + 1);
    hi = min(hi, a + i + c + n);
    if (lo > hi) continue;
    lo = max(lo, d + i + c + 1);
    hi = min(hi, d + i + c + n);
    rs += max(hi - lo + 1, 0LL);
  }
  cout << rs << '\n';
  return 0;
}
