#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long dif;
  dif = max({a + b, a + c, b + d, c + d}) - min({a + b, a + c, b + d, c + d});
  long long ans = n * (n - dif);
  if (dif > n) ans = 0;
  printf("%lld\n", ans);
  return 0;
}
