#include <bits/stdc++.h>
using namespace std;
long long sum[4];
int main(void) {
  long long n, a, b, c, d, min_value = 1e14, max_value = 0, flag = 0;
  scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
  sum[0] = a + b;
  sum[1] = b + d;
  sum[2] = c + d;
  sum[3] = a + c;
  for (int i = 0; i < 4; i++) {
    min_value = min(min_value, sum[i]);
    max_value = max(max_value, sum[i]);
  }
  if (max_value - min_value > n) flag = 1;
  if (flag == 1)
    printf("0");
  else
    printf("%lld", n * (n - (max_value - min_value)));
  return 0;
}
