#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long x2 = b - c;
  long long x4 = a - d;
  long long x5 = b - c + a - d;
  long long mn = min(x2, min(x4, x5));
  if (mn <= -n) {
    cout << 0 << endl;
    return 0;
  }
  if (mn < 0)
    mn = -mn + 1;
  else
    mn = 1;
  long long mx = max(x2, max(x4, x5));
  if (mx >= n) {
    cout << 0 << endl;
    return 0;
  }
  if (mx > 0)
    mx = n - mx;
  else
    mx = n;
  if (mx < mn)
    cout << 0 << endl;
  else
    cout << ((mx - mn + 1) * n) << endl;
  return 0;
}
