#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > v;
map<char, bool> mpp;
map<int, int>::iterator it;
set<string> s;
set<pair<int, int> >::iterator iter;
deque<char> d;
long long a[500001];
int main() {
  ios::sync_with_stdio(false);
  long long n, a, b, c, d, ans = 1, y1, y2, y3, y4;
  cin >> n >> a >> b >> c >> d;
  if (a >= d) {
    y1 = 1;
    y2 = a - d + 1;
  } else {
    y2 = 1;
    y1 = d - a + 1;
  }
  y4 = c + y1 - b;
  y3 = y4 + a - d;
  if (y1 <= 0) {
    y4 += 1 - y1;
    y3 += 1 - y1;
    y2 += 1 - y1;
    y1 += 1 - y1;
  }
  if (y2 <= 0) {
    y4 += 1 - y2;
    y3 += 1 - y2;
    y1 += 1 - y2;
    y2 += 1 - y2;
  }
  if (y3 <= 0) {
    y4 += 1 - y3;
    y1 += 1 - y3;
    y2 += 1 - y3;
    y3 += 1 - y3;
  }
  if (y4 <= 0) {
    y1 += 1 - y4;
    y3 += 1 - y4;
    y2 += 1 - y4;
    y4 += 1 - y4;
  }
  if (y4 > n || y3 > n || y2 > n || y1 > n) {
    cout << 0;
    return 0;
  }
  if (n - max(y1, max(y2, max(y3, y4))) > 0)
    ans += n - max(y1, max(y2, max(y3, y4)));
  cout << ans * n;
  return 0;
}
