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