#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d;
long long sayac;
int main() {
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  for (int x = 1; x <= n; x++) {
    int y = x + b - c;
    int z = x + a - d;
    int t = a + (x + b - c) - d;
    if (1 <= y && y <= n && 1 <= z && z <= n && 1 <= t && t <= n) {
      sayac += n;
    }
  }
  printf("%lld\n", sayac);
}
