#include <bits/stdc++.h>
using namespace std;
const long long nmax = 100005;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long double eps = 1e-9;
const long double PI = acos(-1.0);
const long double big = 1e5;
long long q[10];
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  long long a, b, c, d;
  cin >> n;
  cin >> a >> b >> c >> d;
  long long cnt = 0;
  for (int i = 1; i <= n; ++i) {
    q[1] = i;
    q[2] = b + q[1] - c;
    q[3] = q[1] + a - d;
    q[4] = q[2] + a - d;
    if ((q[2] >= 1) && (q[2] <= n) && (q[3] >= 1) && (q[3] <= n) &&
        (q[4] >= 1) && (q[4] <= n) && (q[3] + b == q[4] + c)) {
      cnt += n;
    }
  }
  cout << cnt << '\n';
  return 0;
}
