#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    int l = 4, r = 4 * n;
    l = max(l, 1 + i + a + b);
    r = min(r, n + a + b + i);
    l = max(l, 1 + i + a + c);
    r = min(r, n + c + a + i);
    l = max(l, 1 + i + d + b);
    r = min(r, n + d + b + i);
    l = max(l, 1 + i + d + c);
    r = min(r, n + d + c + i);
    ans += max((long long)0, 1ll * (r - l + 1));
  }
  cout << ans << endl;
  return 0;
}
