#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int main(int argc, char const *argv[]) {
  int n, a, b, c, d;
  long long int ans = 0;
  scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
  for (int i = 1; i <= n; i++) {
    int x = c + i - b;
    if (x > 0 && x <= n) {
      x = a + x - d;
      if (x > 0 && x <= n) {
        x = a + i - d;
        if (x > 0 && x <= n) {
          ans++;
        }
      }
    }
  }
  printf("%lld\n", ans * n);
  return 0;
}
