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