#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long ac = a + c;
  long long ab = a + b;
  long long bd = b + d;
  long long cd = c + d;
  long long maxx = max(ac, max(ab, max(bd, cd)));
  long long minn = min(ac, min(ab, min(bd, cd)));
  long long ans = 0;
  long long diff = maxx - minn;
  ans = (n - diff) * n;
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}
