#include <bits/stdc++.h>
using namespace std;
bool check(int k, int n) { return (k >= 1 && k <= n) ? true : false; }
int main() {
  ios_base::sync_with_stdio(false);
  ;
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int x2, x4, x5;
  long long int count = 0;
  for (int(x1) = (1); (x1) <= (n); ++(x1)) {
    x2 = (b - c) + x1;
    if (!check(x2, n)) continue;
    x4 = (a - d) + x1;
    if (!check(x4, n)) continue;
    x5 = (a + b) - (c + d) + x1;
    if (!check(x5, n)) continue;
    count += n;
  }
  cout << count << endl;
  return 0;
}
