#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c, d, ans;
void read() {
  scanf("%lld", &n);
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
}
void solve() {
  int x;
  for (x = 1; x <= n; ++x) {
    int w = x + a + b - c - d, t = x + a - d, y = t + b + d - a - c;
    if (w > 0 && w <= n && t > 0 && t <= n && y > 0 && y <= n) ++ans;
  }
  ans = ans * n;
}
void write() { printf("%lld\n", ans); }
int main() {
  read();
  solve();
  write();
  return 0;
}
