#include <bits/stdc++.h>
using namespace std;
long long n;
bool ch(long long first) {
  if (first >= 1 && first <= n) return 1;
  return 0;
}
void solve() {
  long long a, b, c, d, ans = 0;
  cin >> n >> a >> b >> c >> d;
  long long first = c - b, second = d - a, z = c + d - a - b;
  map<pair<long long, pair<long long, long long> >, long long> m2;
  for (long long i = 1; i < n + 1; i++) {
    long long l = i - first, m = i - second, o = i - z;
    if (ch(l) && ch(m) && ch(o) && (m - o == c - b) && (o - l == a - d)) {
      m2[{l, {m, o}}] = 1;
      ans++;
    }
  }
  ans *= n;
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
