#include <bits/stdc++.h>
using namespace std;
static int n, a, b, c, d;
int main() {
  while (scanf("%d%d%d%d%d", &n, &a, &b, &c, &d) != EOF) {
    long long ans = 0;
    int t[4];
    for (int i = 1; i <= n; i++) {
      t[0] = a + b + i;
      t[1] = a + c + i;
      t[2] = b + d + i;
      t[3] = c + d + i;
      int maxium = INT_MIN;
      for (int j = 0; j < 4; j++) {
        for (int k = j + 1; k < 4; k++) maxium = max(maxium, abs(t[j] - t[k]));
      }
      ans += static_cast<long long>((maxium <= n ? n - maxium : 0));
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
