#include <bits/stdc++.h>
using namespace std;
int out(int a, int n) { return !(a >= 1 && a <= n); }
int main() {
  int n, a, b, c, d;
  long long int ct = 0;
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  for (int i = 1; i <= n; i++) {
    int x1 = i;
    int x2 = x1 - c + b;
    int x4 = x2 + a + c - b - d;
    int x5 = x4 + b - c;
    if (out(x1, n) || out(x2, n) || out(x4, n) || out(x5, n)) continue;
    ct++;
  }
  printf("%lld\n", ct * n);
  return 0;
}
