#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, b, c, d, counter = 0;
  cin >> n;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  long long int x = max(a + b, max(a + c, max(b + d, c + d)));
  long long int y = min(a + b, min(a + c, min(b + d, c + d)));
  if (x - y + 1 <= n) {
    cout << (n - (x - y)) * n;
  } else {
    cout << counter;
  }
}
