#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
long long bigmod(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % 1000000007;
    b >>= 1;
    a = (a * a) % 1000000007;
  }
  return ret;
}
long long inverse(long long n) { return bigmod(n, 1000000007 - 2); }
long long add(long long a, long long b) {
  long long ret = a + b;
  if (ret >= 1000000007) ret %= 1000000007;
  return ret;
}
long long subtract(long long a, long long b) {
  long long ret = a - b;
  if (ret < 0) ret += 1000000007;
  return ret;
}
long long mult(long long a, long long b) {
  long long ret = a * b;
  if (ret >= 1000000007) ret %= 1000000007;
  return ret;
}
bool checkBit(int n, int i) { return (n & (1 << i)); }
int setBit(int n, int i) { return (n | (1 << i)); }
int resetBit(int n, int i) { return (n & (~(1 << i))); }
int main() {
  int n, a, b, c, d;
  scanf("%d", &n);
  scanf("%d%d", &a, &b);
  scanf("%d%d", &c, &d);
  int mn = min(a + b, min(a + c, min(b + d, c + d)));
  int mx = max(a + b, max(a + c, max(b + d, c + d)));
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    int tmp = mx + i - mn;
    if (1 <= tmp && tmp <= n) ans += n;
  }
  cout << ans << endl;
  return 0;
}
