#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d;
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int sum = a + b + i;
    if (sum - a - c <= 0 || sum - a - c > n) continue;
    if (sum - b - d <= 0 || sum - b - d > n) continue;
    if (sum - c - d <= 0 || sum - c - d > n) continue;
    ans++;
  }
  ans *= n;
  printf("%I64d", ans);
  return 0;
}
