#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  cin >> w >> h;
  int* height = new int[h + 1];
  for (int i = 0; i <= h; i++) {
    height[i] = 0;
  }
  int u1, d1;
  cin >> u1 >> d1;
  height[d1] = u1;
  int u2, d2;
  cin >> u2 >> d2;
  height[d2] = u2;
  for (int i = h; i >= 0; i--) {
    w += i;
    if (height[i] > w) {
      w = 0;
    } else if (height[i] <= w) {
      w -= height[i];
    }
  }
  cout << w << endl;
  return 0;
}
