#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long A = a + b;
  long long B = b + d;
  long long C = c + d;
  long long D = a + c;
  long long R = max(max(max(A, B), C), D);
  long long r = min(min(min(A, B), C), D);
  long long ans = (n - (R - r)) * n;
  if (ans > 0)
    cout << ans << endl;
  else
    cout << "0" << endl;
  return 0;
}
