#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long p, q, r, s, ans = 0;
  for (int i = 1; i <= n; ++i) {
    p = i;
    q = p + b - c;
    r = p + a - d;
    if (q + a - d != r + b - c) continue;
    s = q + a - d;
    if (q < 1 or q > n) continue;
    if (r < 1 or r > n) continue;
    if (s < 1 or s > n) continue;
    ans++;
  }
  ans = ans * n;
  cout << ans;
}
