#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
long long a, b, c, d, n, ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> a >> b >> c >> d;
  for (int i = 1; i <= n; ++i) {
    int e = i;
    int x = e + b - c;
    int t = e + a + b - c - d;
    int z = e + a - d;
    if (x > 0 && t > 0 && z > 0 && x <= n && t <= n && z <= n) ans += n;
  }
  cout << ans << endl;
}
