#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
void debug(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long ans = 0;
  for (int x = (1); x < (n + 1); ++x) {
    int y = x + b - c;
    if (y < 1 or y > n) continue;
    int w = x + a - d;
    if (w < 1 or w > n) continue;
    int v = a + y - d;
    if (v < 1 or v > n) continue;
    ans += n;
  }
  cout << ans << "\n";
  return 0;
}
