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