#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long int arr[4];
  arr[0] = a + b;
  arr[1] = a + c;
  arr[2] = c + d;
  arr[3] = b + d;
  sort(arr, arr + 4);
  long long int ans = 0;
  ans = n * (n - (arr[3] - arr[0]));
  if (ans <= 0)
    cout << "0";
  else
    cout << ans << endl;
  return 0;
}
