#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
signed long long n, ans;
signed long long d[10];
void pr() {
  for (int i = 0; i < (9); i++) {
    cout << d[i + 1];
    if (i % 3 == 2) cout << endl;
  }
  cout << endl;
}
int main() {
  cin >> n >> d[2] >> d[4] >> d[6] >> d[8];
  for (int i = 1; i <= n; i++) {
    d[1] = i;
    d[3] = d[4] + d[1] - d[6];
    d[7] = d[2] + d[1] - d[8];
    d[9] = d[2] + d[4] + d[1] - d[6] - d[8];
    bool ok = 1;
    for (int j = 1; j < 10; j += 2) {
      if (j == 5) continue;
      if (d[j] < 1 || d[j] > n) ok = 0;
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans * n << endl;
  return 0;
}
