#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  char ch = getchar();
  long long fh = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  x *= fh;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
long long n, a, b, c, d, ans;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> a >> b >> c >> d;
  for (long long x = 1; x <= n; x++) {
    if ((a + x - d) >= 1 && (a + x - d) <= n && (b + x - c) >= 1 &&
        (b + x - c) <= n && (a + b - c - d + x) >= 1 &&
        (a + b - c - d + x) <= n)
      ans += n;
  }
  cout << ans << endl;
  return 0;
}
