#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, n;
int main() {
  while (~scanf("%I64d%I64d%I64d%I64d%I64d", &n, &a, &b, &c, &d)) {
    long long mi = min(b - c, min(a - d, a + b - c - d)),
              ma = max(b - c, max(a - d, a + b - c - d));
    long long num1 = min(n - ma, n), num2 = max(1 - mi, (long long)1), ans = 0;
    ;
    if (num1 < num2)
      ans = 0;
    else
      ans = num1 - num2 + 1;
    printf("%I64d\n", n * ans);
  }
  return 0;
}
