#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A[4];
  while (cin >> N) {
    for (int i = 0; i < (int)(4); i++) cin >> A[i];
    swap(A[2], A[3]);
    long long ans = 0;
    for (int x = 1; x <= N; ++x) {
      int s_lb = INT_MIN, s_ub = INT_MAX;
      for (int i = 0; i < (int)(4); i++) {
        int t = x + A[i] + A[(i + 1) % 4];
        s_lb = max(s_lb, t + 1);
        s_ub = min(s_ub, t + N);
      }
      ans += max(0, s_ub - s_lb + 1);
    }
    cout << ans << endl;
  }
}
