#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  cin >> w >> h;
  int u[2], d[2];
  for (int i = 0; i < 2; i++) cin >> u[i] >> d[i];
  while (h > 0) {
    w += h;
    if (h == d[0]) w -= u[0];
    if (h == d[1]) w -= u[1];
    if (w < 0) w = 0;
    h--;
  }
  cout << w;
}
