#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
int n;
int main() {
  auto f = stdin;
  fscanf(f, "%d %d %d %d %d", &n, &a, &b, &c, &d);
  uint64_t res = 0;
  for (int i = 1; i <= n; ++i) {
    int s1 = i + a - d;
    int s2 = i + b - c;
    int s3 = i + a + b - c - d;
    if (s1 >= 1 && s1 <= n && s2 >= 1 && s2 <= n && s3 >= 1 && s3 <= n) ++res;
  }
  res *= n;
  cout << res << endl;
  return 0;
}
