#include <bits/stdc++.h>
using namespace std;
long long int mi(long long int a, long long int b) {
  if (a < b) return a;
  return b;
}
long long int ma(long long int a, long long int b) {
  if (a < b) return b;
  return a;
}
int main() {
  long long int a, b, c, d, n;
  cin >> n >> a >> b >> c >> d;
  long long int v = a + b, x = a + c, y = b + d, z = c + d;
  long long int MAX = ma(v, (ma(x, ma(y, z))));
  long long int MIN = mi(v, (mi(x, mi(y, z))));
  long long int q = n - (MAX - MIN);
  if (q < 0) q = 0;
  cout << q * n;
  return 0;
}
