#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long mi = 1;
  long long ma = n;
  if (a > d) {
    ma = d + n - a;
  } else {
    mi = d + 1 - a;
  }
  if (b > c) {
    ma = min(ma, c + n - b);
  } else {
    mi = max(mi, c + 1 - b);
  }
  if (a + b > c + d) {
    ma = min(ma, c + d + n - a - b);
  } else {
    mi = max(mi, c + d + 1 - a - b);
  }
  if (mi > ma) {
    cout << "0\n";
  } else {
    cout << n * (ma - mi + 1) << endl;
  }
}
