#include <bits/stdc++.h>
using namespace std;
const double g = 10.0, eps = 1e-12;
const int N = 100000 + 10, maxn = 2000 + 10, inf = 0x3f3f3f3f;
int main() {
  long long n, a, b, c, d;
  scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
  long long ans = n;
  long long te1 = a + b, te2 = a + c, te3 = b + d, te4 = c + d;
  long long te =
      max(te1, max(te2, max(te3, te4))) - min(te1, min(te2, min(te3, te4)));
  te = max(0ll, te);
  te = min(n, te);
  te = n - te;
  printf("%lld\n", ans * te);
  return 0;
}
