#include <bits/stdc++.h>
using namespace std;
int slope[150 + 1];
int main(void) {
  int w, h;
  scanf("%d%d", &w, &h);
  for (int i = 0; i < 2; i++) {
    int ww, hh;
    scanf("%d%d", &ww, &hh);
    slope[hh] = ww;
  }
  while (h > 0) {
    w += h;
    if (slope[h] > 0) w = max(0, w - slope[h]);
    h--;
  }
  printf("%d\n", w);
  return 0;
}
