#include <bits/stdc++.h>
using namespace std;
int sum(int a) { return ((a * (a + 1)) / 2); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int w, h, u1, h1, u2, h2;
  cin >> w >> h >> u1 >> h1 >> u2 >> h2;
  if (h2 > h1) {
    std::swap(h2, h1);
    std::swap(u2, u1);
  }
  int add = sum(h);
  int snow = w;
  int favour = sum(h1 - 1);
  snow += add - favour;
  if (snow < u1) {
    snow = 0;
  } else {
    snow -= u1;
  }
  int end = h1;
  int start = h2 - 1;
  start = sum(start);
  int last = add - start;
  last -= add - sum(end - 1);
  snow += last;
  if (snow < u2) {
    snow = 0;
  } else {
    snow -= u2;
  }
  snow += sum(h2 - 1);
  cout << snow;
  return 0;
}
