#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, n;
  cin >> n >> a >> b >> c >> d;
  long long ans = 0;
  for (int v11 = 1; v11 <= n; ++v11) {
    int v[4][4];
    memset(v, 0, sizeof v);
    v[1][1] = v11;
    v[1][2] = a;
    v[2][1] = b;
    v[2][3] = c;
    v[3][2] = d;
    v[1][3] = b + v11 - c;
    v[3][1] = a + v11 - d;
    v[3][3] = a + v[1][3] - d;
    int bad = 0;
    for (int i = 1; i <= 3; ++i)
      for (int j = 1; j <= 3; ++j)
        if (i == 2 && j == 2)
          continue;
        else if (v[i][j] < 1 || v[i][j] > n) {
          bad = 1;
          break;
        }
    if (!bad) ans += n;
  }
  cout << ans << endl;
}
