#include <bits/stdc++.h>
using namespace std;
template <typename T>
void pr(vector<T> &v) {
  for (int i = 0; i < (int)(v).size(); i++) cout << v[i] << " ";
  cout << endl;
}
template <typename T>
void pr(vector<vector<T>> &v) {
  for (int i = 0; i < (int)(v).size(); i++) {
    pr(v[i]);
  }
}
template <typename T>
void re(T &first) {
  cin >> first;
}
template <typename T>
void re(vector<T> &a) {
  for (int i = 0; i < (int)(a).size(); i++) re(a[i]);
}
template <class Arg, class... Args>
void re(Arg &first, Args &...rest) {
  re(first);
  re(rest...);
}
template <typename T>
void pr(T first) {
  cout << first << endl;
}
template <class Arg, class... Args>
void pr(const Arg &first, const Args &...rest) {
  cout << first << " ";
  pr(rest...);
  cout << endl;
}
template <typename T>
void pr1(string &first, T &second) {
  cout << first << ": " << second << endl;
}
int main() {
  int w, h;
  re(w, h);
  int u1, u2, d1, d2;
  re(u1, d1, u2, d2);
  while (h > 0) {
    w += h;
    if (h == d1) {
      w -= u1;
    }
    if (h == d2) {
      w -= u2;
    }
    if (w < 0) w = 0;
    h--;
  }
  pr(w);
}
