#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  cin >> w >> h;
  int w1, h1;
  cin >> w1 >> h1;
  int w2, h2;
  cin >> w2 >> h2;
  if (h2 > h1) {
    swap(h2, h1);
    swap(w2, w1);
  }
  while (h >= h1) {
    w += h;
    h--;
  }
  w -= w1;
  w = max(0, w);
  while (h >= h2) {
    w += h;
    h--;
  }
  w -= w2;
  w = max(0, w);
  while (h > 0) {
    w += h;
    h--;
  }
  cout << w << endl;
}
