#include <bits/stdc++.h>
using namespace std;
long long res, a, b, c, d, n, v, w, x, y, z, val;
int main() {
  cin >> n >> a >> b >> c >> d;
  val = c + d - b - a;
  for (v = 1; v <= n; v++) {
    w = v + b - c;
    y = v + a - d;
    z = b + y - c;
    if (w >= 1 && y >= 1 && z >= 1 && w <= n && y <= n && z <= n) res += n;
  }
  cout << res << endl;
  return 0;
}
