#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
int n, a, b, c, d;
bool first(int x) { return (1 <= x && x <= n); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> a >> b >> c >> d;
  set<pair<pair<int, int>, pair<int, int>>> S;
  for (int x11 = 1; x11 <= n; x11++) {
    int x13 = x11 - c + b;
    int x31 = x11 - d + a;
    int x33 = x11 + a + b - d - c;
    if (first(x13) && first(x31) && first(x33)) {
      S.insert({{x11, x13}, {x31, x33}});
    }
  }
  cout << n * 1ll * (int)(S).size() << "\n";
  return 0;
}
