#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, t, i, a, b, c, d, temp, temp1, temp2;
  vector<long long> arr(4);
  cin >> n >> a >> b >> c >> d;
  arr[0] = 1 - (b - c);
  arr[1] = 1 - (a - d);
  arr[2] = 1 - (a + b - c - d);
  arr[3] = 1;
  sort(arr.begin(), arr.end());
  temp = arr[3];
  arr[0] = n - (b - c);
  arr[1] = n - (a - d);
  arr[2] = n - (a + b - c - d);
  arr[3] = n;
  sort(arr.begin(), arr.end());
  temp1 = arr[0];
  if (((temp1 - temp + 1) * n) < 0)
    cout << 0 << endl;
  else
    cout << (temp1 - temp + 1) * n;
}
