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