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