#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:64000000")
const int infi = 1e9 + 7;
const long long infl = 1e18 + 7;
const int cnt_mod = 10;
long long mod[cnt_mod];
int check(int a) {
  for (int i = 2; i * i <= a; ++i) {
    if (a % i == 0) return 0;
  }
  return 1;
}
void calc_mod() {
  int cnt = 0;
  for (int i = 1e9 + 1; cnt < cnt_mod; ++i) {
    if (check(i)) mod[cnt++] = i;
  }
  return;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int s[] = {a + b, a + c, d + b, d + c};
  int mn = infi, mx = -infi;
  for (int i = 0; i < 4; ++i) mn = min(mn, s[i]), mx = max(mx, s[i]);
  cout << max((long long)n * (n - (mx - mn)), 0LL);
  return 0;
}
