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