#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010101;
int a, b, c, d, n;
int e, f;
int main() {
  long long aams = 0;
  scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
  for (int i = 1; i <= n; i++) {
    int maxx = 1;
    int minn = 1;
    e = 1 + a + b + i;
    int zz = e - a - c - i;
    if (minn > zz) minn = zz;
    if (maxx < zz) maxx = zz;
    zz = e - c - d - i;
    if (minn > zz) minn = zz;
    if (maxx < zz) maxx = zz;
    zz = e - a - b - i;
    if (minn > zz) minn = zz;
    if (maxx < zz) maxx = zz;
    zz = e - b - d - i;
    if (minn > zz) minn = zz;
    if (maxx < zz) maxx = zz;
    int mm = 1 - minn;
    int nn = n - maxx;
    int ans = nn - mm + 1;
    if (ans >= 0) {
      aams += (long long)ans;
    }
  }
  printf("%I64d\n", aams);
}
