#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
const long double PI = 3.14159265358979323;
long long int linf = (long long int)2e18;
const long long int inf = 1011111111;
const long long int N = 200005;
long long int n, a, b, c, d;
void input() { cin >> n >> a >> b >> c >> d; }
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int test = 1;
  while (test--) {
    input();
    long long int ans = 0;
    vector<long long int> v1;
    v1.push_back(a + b);
    v1.push_back(a + c);
    v1.push_back(b + d);
    v1.push_back(c + d);
    sort((v1).begin(), (v1).end());
    long long int diff = v1[3] - v1[0];
    if (diff >= n) {
      cout << ans << "\n";
      continue;
    }
    ans = n * (n - diff);
    cout << ans << "\n";
  }
  cerr << '\n'
       << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
