#include <bits/stdc++.h>
using namespace std;
int n;
int ret;
int a, b, c, d;
bool in(int x) { return x >= 1 && x <= n; }
int main() {
  cin >> n >> a >> b >> c >> d;
  for (int i = 1; i <= n; ++i) {
    int u = i + b - c;
    int v = i + d - a;
    int l = i + b - c + d - a;
    if (in(u) && in(v) && in(l)) ++ret;
  }
  cout << (long long)ret * n << endl;
  return 0;
}
