#include <bits/stdc++.h>
using namespace std;
int n;
int s, h;
int s1, h1, s2, h2;
int main() {
  scanf("%d%d", &s, &h);
  scanf("%d%d%d%d", &s1, &h1, &s2, &h2);
  if (h1 < h2) {
    swap(h1, h2);
    swap(s1, s2);
  }
  s = s + ((h1 + h) * (h - h1 + 1)) / 2;
  s = max(0, s - s1);
  s = s + ((h1 - 1 + h2) * (h1 - h2)) / 2;
  s = max(0, s - s2);
  s = s + ((h2) * (h2 - 1)) / 2;
  printf("%d\n", s);
  return 0;
}
