#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d;
  while (cin >> n >> a >> b >> c >> d) {
    int x, y, k, w;
    long long int cnt = 0;
    for (x = 1; x <= n; x++) {
      int y = (a + b + x) - a - c;
      int w = (a + b + x) - b - d;
      int k = (a + b + x) - c - d;
      if (y >= 1 && y <= n && w >= 1 && w <= n && k >= 1 && k <= n) {
        cnt++;
      }
    }
    cout << cnt * n << endl;
  }
  return 0;
}
