#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, n, sum, ans = 0;
int main() {
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  for (int i = 1; i <= n; ++i) {
    sum = a + b + i;
    if ((sum - a - c) < 1 || (sum - a - c) > n) continue;
    if ((sum - b - d) < 1 || (sum - b - d) > n) continue;
    if ((sum - d - c) < 1 || (sum - d - c) > n) continue;
    ++ans;
  }
  cout << ans * n;
}
