#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int N = 142123;
int n, a, b, c, d, s, ce;
long long ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> b >> ce >> d;
  for (int i = 1; i <= n; ++i) {
    s = a + b + i;
    c = s - a - ce;
    if (c < 1 || n < c) continue;
    c = s - b - d;
    if (c < 1 || n < c) continue;
    c = s - ce - d;
    if (c < 1 || n < c) continue;
    ans += n;
  }
  cout << ans;
}
