#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using vll = std::vector<ll>;
constexpr ll BIGLL{std::numeric_limits<ll>::max()};
constexpr ld BIGLD{std::numeric_limits<ld>::max()};
constexpr ll LL10{10000000000 + 1};
template <typename t, typename t2>
auto min(t&& a, t2&& b) -> decltype(a + b) {
  return a < b ? a : b;
}
template <typename t, typename t2>
auto max(t&& a, t2&& b) -> decltype(a + b) {
  return a > b ? a : b;
}
template <typename N>
ll multimax_impl(ll cur, N last) {
  return max(cur, last);
}
template <typename N, typename... VALS>
ll multimax_impl(ll cur, N n, VALS... vals) {
  return multimax_impl(max(cur, n), vals...);
}
template <typename... VALS>
ll multimax(VALS... values) {
  return multimax_impl(-BIGLL, values...);
}
constexpr bool check(ll n, ll l) { return (n >= 1 && n <= l); }
int main() {
  ios_base::sync_with_stdio(false);
  ll n{0};
  cin >> n;
  ;
  ll a{0};
  cin >> a;
  ;
  ll b{0};
  cin >> b;
  ;
  ll c{0};
  cin >> c;
  ;
  ll d{0};
  cin >> d;
  ;
  ll t = multimax(a + b + 1, a + c + 1, c + d + 1, b + d + 1);
  t = multimax(t - a - b, t - a - c, t - c - d, t - b - d);
  if (n < t)
    cout << 0 << endl;
  else {
    cout << n * (n - t + 1) << endl;
  }
  return 0;
}
