#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 55;
int n, a, b, c, d, x1, x2, x3, x4, x5;
int main() {
  cin >> n >> a >> b >> c >> d;
  long long ans = 0;
  for (x1 = 1; x1 <= n; x1++) {
    x2 = b + x1 - c;
    x4 = x1 + a - d;
    x5 = x1 + a + b - c - d;
    int sum1, sum2, sum3, sum4;
    sum1 = x1 + a + b;
    sum2 = x2 + a + c;
    sum3 = c + d + x5;
    sum4 = b + d + x4;
    if (x2 > 0 && x4 > 0 && x5 > 0 && x2 <= n && x4 <= n && x5 <= n &&
        sum1 == sum2 && sum1 == sum3 && sum1 == sum4)
      ans += n;
  }
  cout << ans;
}
