#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);
  int mins = (a + b);
  mins = min(mins, a + c);
  mins = min(mins, c + d);
  mins = min(mins, b + d);
  int maxs = (a + b);
  maxs = max(maxs, a + c);
  maxs = max(maxs, c + d);
  maxs = max(maxs, b + d);
  int diff = maxs - mins;
  if (diff >= n) {
    printf("0\n");
  } else {
    long long t = n - diff;
    printf("%I64d\n", t * n);
  }
  return 0;
}
