#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d;
  long long int counter = 0;
  cin >> n >> a >> b >> c >> d;
  int arr[4], arr1[4];
  arr[0] = a + b;
  arr[1] = a + c;
  arr[2] = b + d;
  arr[3] = c + d;
  for (long i = 1; i <= n; i++) {
    int j = i - b + c;
    int k = i - a + d;
    int l = j - a + d;
    if ((j >= 1 && j <= n) && (k >= 1 && k <= n) && (l >= 1 && l <= n)) {
      counter++;
    }
  }
  counter = counter * n;
  cout << counter << endl;
}
