#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, d, s1, s2, s3, s4, ans = 0;
  cin >> n >> a >> b >> c >> d;
  s1 = a + b;
  s2 = a + c;
  s3 = b + d;
  s4 = c + d;
  for (long long i = 1; i <= n; i++) {
    long long d2 = s1 + i - s2;
    long long d3 = s1 + i - s3;
    long long d4 = s1 + i - s4;
    if (d2 > 0 && d3 > 0 && d4 > 0 && d2 <= n && d3 <= n && d4 <= n) ans += n;
  }
  cout << ans << '\n';
  return 0;
}
