#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  vector<long long> cons = {a - d, a + b - c - d, b - c};
  long long maxn = *max_element(cons.begin(), cons.end());
  long long minn = *min_element(cons.begin(), cons.end());
  long long able = n - max(0LL, maxn) + min(0LL, minn);
  if (able < 0) able = 0;
  cout << (able * n) << endl;
  return 0;
}
