#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d, e, f, g, h, j;
  long long cnt = 0;
  cin >> n >> a >> b >> c >> d;
  for (e = 1; e <= n; e++) {
    f = e + b - c;
    h = e + a - d;
    j = e + a + b - c - d;
    if ((f >= 1 && f <= n) && (h >= 1 && h <= n) && (j >= 1 && j <= n)) cnt++;
  }
  cnt *= n;
  cout << cnt;
  return 0;
}
