#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    long long i, j, n, a, b, c, d, mx, mn;
    cin >> n >> a >> b >> c >> d;
    mx = max(a + b, a + c);
    mx = max(mx, b + d);
    mx = max(mx, c + d);
    mn = min(a + b, a + c);
    mn = min(mn, b + d);
    mn = min(mn, c + d);
    if (mx + 1 <= mn + n) {
      i = min(a + b + n, mn + n);
      j = max(mx + 1, a + b + 1);
      cout << n * (i - j + 1);
    } else
      cout << "0";
  }
  return 0;
}
