#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d;
int center(int e) {
  int donja_sum = 1 + e + max(a + b, max(a + c, max(b + d, c + d)));
  int gornja_sum = n + e + min(a + b, min(a + c, min(b + d, c + d)));
  int donja = donja_sum - e - a - b;
  int gornja = gornja_sum - e - a - b;
  return max(0, gornja - donja + 1);
}
int main() {
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  long long res = 0;
  for (int i = 1; i <= n; ++i) {
    res += center(i);
  }
  printf("%lld\n", res);
  return 0;
}
