#include <bits/stdc++.h>
using namespace std;
long long int n, a, b, c, d, ans, p1, p2, k, p3, p4;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> a >> b >> c >> d;
  for (int i = 1; i <= n; i++) {
    p1 = max((a + b + i), (b + i + d));
    p2 = min((a + b + i), (b + i + d));
    p3 = max(a + c + i, i + c + d);
    p4 = min(a + c + i, i + c + d);
    p1 = max(p1, p3);
    p2 = min(p2, p4);
    if (p1 == p2) {
      ans += n;
    } else if (p1 - p2 >= n)
      ;
    else {
      ans += n - (p1 - p2);
    }
  }
  cout << ans;
  return 0;
}
