#include <bits/stdc++.h>
inline int Rand() { return (rand() << 16) | rand(); }
using namespace std;
const int N = 200005;
const double eps = 1e-9;
int main() {
  long long a, b, c, d, n;
  cin >> n >> a >> b >> c >> d;
  if (abs(b - c) + abs(a - d) >= n)
    cout << 0;
  else
    cout << n * (n - (abs(b - c) + abs(a - d)));
  return 0;
}
