#include <bits/stdc++.h>
long n, a, b, c, d;
long long ans = 0;
bool check(int m) { return m > 0 && m <= n; }
int main() {
  scanf("%ld %ld %ld %ld %ld", &n, &a, &b, &c, &d);
  for (long i = 1; i <= n; i++)
    if (check(i + b - c) && check(i + a - d) && check(i + a + b - c - d))
      ans += n;
  printf("%I64d", ans);
  return 0;
}
