#include <bits/stdc++.h>
using namespace std;
int max(int a, int b) { return a > b ? a : b; }
int main() {
  int n, a, b, c, d;
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
  int aa, bb, cc, dd;
  aa = a + b - (c + d);
  if (aa < 0) {
    aa = -aa + 1;
    dd = 1;
  } else if (aa == 0) {
    aa = 1;
    dd = 1;
  } else {
    dd = aa + 1;
    aa = 1;
  }
  bb = aa + b - c;
  if (bb <= 0) {
    aa += 1 - bb;
    dd += 1 - bb;
    bb = 1;
  }
  cc = dd + c - b;
  if (cc <= 0) {
    aa += 1 - cc;
    bb += 1 - cc;
    dd += 1 - cc;
    cc = 1;
  }
  long long ans = max(aa, max(bb, max(cc, dd)));
  ans = (n - ans + 1) * n;
  bool flag = true;
  if (aa > n || bb > n || cc > n || dd > n) flag = false;
  printf("%I64d\n", flag ? ans : 0);
  return 0;
}
