#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h;
  cin >> w >> h;
  vector<pair<int, int>> v;
  int i, x, y;
  for (i = 0; i < 2; i++) {
    cin >> x >> y;
    v.push_back(make_pair(y, x));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  long long sum = w;
  for (i = v[0].first; i <= h; i++) {
    sum += i;
  }
  if (sum <= v[0].second) {
    sum = 0;
  } else {
    sum = sum - v[0].second;
  }
  for (i = v[1].first; i < v[0].first; i++) {
    sum += i;
  }
  if (sum <= v[1].second) {
    sum = 0;
  } else {
    sum = sum - v[1].second;
  }
  for (i = 1; i < v[1].first; i++) {
    sum += i;
  }
  cout << sum;
}
