#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long res = 0;
  int ab = a + b;
  int ac = a + c;
  int bd = b + d;
  int cd = c + d;
  long long maxnum = max(ab, max(ac, max(bd, cd)));
  long long minnum = min(ab, min(ac, min(bd, cd)));
  long long dif = maxnum - minnum;
  if (dif + 1 > n) {
    cout << 0 << endl;
    return 0;
  } else
    cout << (n - dif) * n << endl;
  return 0;
}
