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