#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int MAX = 1000000007;
const double EPS = 0.000001;
int n, a, b, c, d;
long long ans = (long long)0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> a >> b >> c >> d;
  for (int one = 1; one <= n; one++) {
    int three = one + b - c;
    if (three >= 1 && three <= n) {
      int four = one + a - d;
      if (four >= 1 && four <= n) {
        int five = four + b - c;
        if (five >= 1 && five <= n) ans++;
      }
    }
  }
  ans *= (long long)n;
  cout << ans;
  return 0;
}
