#include <bits/stdc++.h>
using namespace std;
const double EPS = (1e-12);
const double PI = acos(-1);
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
int main() {
  ios_base::sync_with_stdio(0);
  int a, b, c, d, n;
  cin >> n >> a >> b >> c >> d;
  int x2 = a + c;
  int x1 = a + b;
  int x3 = c + d;
  int x4 = b + d;
  int mx = max(max(x1, x2), max(x3, x4));
  int mn = min(min(x1, x2), min(x3, x4));
  long long ans = max(1LL * n * (n - mx + mn), 0LL);
  cout << ans << endl;
  return 0;
}
