#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long ans = max(n - max(a, d) - max(b, c) + min(a, d) + min(b, c), 0);
  ans *= n;
  cout << ans << endl;
  return 0;
}
