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