#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, n;
  cin >> n >> a >> b >> c >> d;
  long long i;
  long long x0, x1, x2, x3, x4;
  long long sum = 0;
  for (x0 = 1; x0 <= n; x0++) {
    long long min1 = 99999999999999;
    long long max1 = -999;
    long long sum1 = a + b + x0;
    min1 = min(min1, sum1);
    max1 = max(max1, sum1);
    long long sum2 = a + c + x0;
    min1 = min(min1, sum2);
    max1 = max(max1, sum2);
    long long sum3 = b + d + x0;
    min1 = min(min1, sum3);
    max1 = max(max1, sum3);
    long long sum4 = c + d + x0;
    min1 = min(min1, sum4);
    max1 = max(max1, sum4);
    if (min1 + n > max1) sum = sum + (min1 + n - max1);
  }
  cout << sum << endl;
}
