#include <bits/stdc++.h>
using namespace std;
class TaskB {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n, a, b, c, d;
    in >> n >> a >> b >> c >> d;
    long long int res = 0;
    for (int i = 1; i <= n; i++) {
      int p = i;
      if ((p - c + b >= 1 && p - c + b <= n) &&
          (p - d + a >= 1 && p - d + a <= n) &&
          (p + a + b - c - d >= 1 && p + a + b - c - d <= n))
        res++;
    }
    out << res * n;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  TaskB solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
