#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
signed main() {
  long long n, a, b, c, d, ans = 0;
  cin >> n >> a >> b >> c >> d;
  for (int i = 1; i < n + 1; ++i) {
    long long x = i + a - d;
    long long y = i + b - c;
    long long z = x + b - c;
    if (x > 0 && x <= n && y <= n && z <= n && y > 0 && z > 0) ans++;
  }
  cout << ans * n;
  return 0;
}
