#include <bits/stdc++.h>
using namespace std;
void solve(int test_number);
void pre() {
  cout.setf(ios::fixed);
  cout.precision(20);
  cerr.setf(ios::fixed);
  cerr.precision(3);
}
void post() {
  fprintf(stderr, "\n");
  fprintf(stderr, "Execution time: %Lf", (long double)clock());
}
const int MAXN = 100100;
inline bool can(long long a, long long n) { return (a >= 1 && a <= n); }
inline void solve(long long test_number) {
  long long n, a, b, c, d;
  scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (can(i + a + b - c - d, n) && can(i + a - d, n) && can(i + b - c, n)) {
      ans += n;
    }
  }
  printf("%lld", ans);
  return;
}
int main() {
  pre();
  long long n = 1;
  for (long long i = 0; i < n; i++) {
    solve(i + 1);
  }
  post();
  return 0;
}
