#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
  int a, b, c, d, n;
  cin >> n >> a >> b >> c >> d;
  int s[4];
  s[0] = a + b;
  s[1] = a + c;
  s[2] = b + d;
  s[3] = c + d;
  int mx = s[0];
  int mn = s[0];
  for (int i = 0; i < 4; ++i) {
    mx = max(mx, s[i]);
    mn = min(mn, s[i]);
  }
  long long cnt = 0;
  for (int i = 1; i <= n; ++i) {
    int tmp_mx = mx + i;
    int tmp_mn = mn + i;
    cnt += max(n - (tmp_mx - tmp_mn), 0);
  }
  cout << cnt;
  return 0;
}
