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