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