#include <bits/stdc++.h>
using namespace std;
long long n, a, b, c, d, res = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> a >> b >> c >> d;
  for (int i = 1; i <= n; ++i) {
    int p = i + b - c;
    int q = p + a - d;
    int r = i + a - d;
    if (0 < p && p <= n && 0 < q && q <= n && 0 < r && r <= n) res += n;
  }
  cout << res;
  return 0;
}
