#include <bits/stdc++.h>
using namespace std;
constexpr int MOD = 10 * 10000 * 10000 + 7;
constexpr int INF = 5 * 10000 * 10000;
constexpr int64_t INFLL = 100000LL * 100000LL * 100000LL;
template <class T, size_t size>
constexpr inline std::string_view AsStringView(const T (&str)[size]) {
  return std::string_view(str, size - 1);
}
void solve() {
  int w, h;
  cin >> w >> h;
  vector<int> wb(h + 1);
  for (int i = 0; i < 2; ++i) {
    int u, d;
    cin >> u >> d;
    wb[d] = u;
  }
  for (int i = h; i >= 0; --i) {
    w += i;
    w -= wb[i];
    w = max(0, w);
  }
  cout << w << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
