#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline void set_bit(int &n, int b) { n |= (1ll << (b)); }
inline void unset_bit(int &n, int b) { n &= ~(1ll << (b)); }
inline void check(long long &x) {
  if (x >= MOD) x %= MOD;
}
int main() {
  long long n, a, b, c, d;
  long long ans = 0;
  cin >> n >> a >> b >> c >> d;
  for (int i = 1; i <= n; i++) {
    long long sum = i + a + b;
    long long sum2 = c + a;
    long long sum3 = b + d;
    long long sum4 = c + d;
    bool f = true;
    if (sum - sum2 >= 1 and sum - sum2 <= n)
      ;
    else
      f = false;
    if (sum - sum3 >= 1 and sum - sum3 <= n)
      ;
    else
      f = false;
    if (sum - sum4 >= 1 and sum - sum4 <= n)
      ;
    else
      f = false;
    if (f) ans++;
  }
  ans *= n;
  cout << ans << "\n";
  return 0;
}
