#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  int p, q, r, s, t, x, y, z;
  x = c - b;
  y = d - a;
  z = x + y;
  int m = max(max(x, y), z);
  if (m < 0) {
    p = 1;
  } else {
    p = m + 1;
  }
  long long int count = 0;
  while (1) {
    t = p - z;
    s = p - y;
    q = p - x;
    if (p > n || q > n || s > n || t > n) {
      break;
    } else {
      count += n;
    }
    p++;
  }
  cout << count;
  return 0;
}
