#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 ans = 0;
  for (int i = 1; i <= n; i++) {
    int x4 = a + i - d;
    int x5 = x4 + b - c;
    int x2 = d + x5 - a;
    if (x4 <= 0 || x4 > n || x5 <= 0 || x5 > n || x2 <= 0 || x2 > n) continue;
    ans++;
  }
  printf("%lld\n", 1LL * ans * n);
}
