#include <bits/stdc++.h>
int min, max;
int main() {
  int e, f, n, a, g, h, i, j, b, c, d;
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  min = 1;
  max = n;
  e = c + 1 - b;
  f = n + c - b;
  g = c + d - a - b + 1;
  h = c + d - a - b + n;
  i = 1 + d - a;
  j = n + d - a;
  if (e > min) {
    min = e;
  }
  if (g > min) {
    min = g;
  }
  if (i > min) {
    min = i;
  }
  if (f < max) {
    max = f;
  }
  if (h < max) {
    max = h;
  }
  if (j < max) {
    max = j;
  }
  if (min <= max) {
    printf("%I64d\n", (long long int)n * (max - min + 1));
  } else {
    printf("0\n");
  }
  return 0;
}
