#include <bits/stdc++.h>
using namespace std;
int ans[502][502];
int gcd(int x, int y) {
  if (x == 1 || y == 1) return 1;
  if (x % y == 0) return y;
  if (y % x == 0) return x;
  if (x > y)
    return gcd(x % y, y);
  else
    return gcd(x, y % x);
}
long long arr[7];
signed main() {
  ifstream in("Text.txt");
  long long n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  long long ans = 0;
  arr[0] = abs(c - b);
  arr[1] = abs(d - a);
  arr[2] = abs(c - b);
  arr[3] = abs(d - a);
  arr[4] = abs(c + d - a - b);
  arr[5] = abs(a + c - b - d);
  for (int i = 0; i < 7; i++) ans = max(ans, arr[i]);
  ans = (n - ans) * n;
  ans = max(ans, (long long)0);
  cout << ans << endl;
  return 0;
}
