#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b, c, d;
  while (cin >> n >> a >> b >> c >> d) {
    int arr[] = {a + b, b + d, c + d, c + a};
    sort(arr, arr + 4);
    arr[3]++;
    int t = arr[3] - arr[0];
    if (t > n)
      cout << 0 << "\n\n";
    else
      cout << (n - t + 1LL) * n << "\n\n";
  }
}
