#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);
  long long ans = 0;
  for (int x = 1; x <= n; x++) {
    if (1 <= x + b - c && x + b - c <= n)
      if (1 <= x + a - d && x + a - d <= n)
        if (1 <= x + a + b - c - d && x + a + b - c - d <= n) ans += n;
  }
  cout << ans << '\n';
  return 0;
}
