#include <bits/stdc++.h>
using namespace std;
long long int satisfays(long long int dif, long long int difdown,
                        long long int n) {
  if (1 + dif > n or 1 + difdown > n) return 0;
  return n - dif - difdown;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long int ans = n;
  long long int difup = max(b - c, c - b);
  long long int difdown = max(a - d, d - a);
  ans *= satisfays(difup, difdown, n);
  cout << max(ans, 0LL) << endl;
  return 0;
}
