#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U> &l, const std::pair<T, U> &r) {
  return {l.first + r.first, l.second + r.second};
}
const long double PI_L = acos(-1.0L);
struct Point {
  long double x, y;
  Point() {}
  Point(long double _x, long double _y) {
    x = _x;
    y = _y;
  }
};
long double dotProd(Point &a, Point &b) { return a.x * b.y + a.y * b.x; }
long double squaredDist(Point &a, Point &b) {
  long double xDiff = a.x - b.x;
  long double yDiff = a.y - b.y;
  return xDiff * xDiff + yDiff * yDiff;
}
long double angle(Point &origin, Point &a, Point &b) {
  Point p1(a.x - origin.x, a.y - origin.y);
  Point p2(b.x - origin.x, b.y - origin.y);
  long double squaredLen1 = p1.x * p1.x + p1.y * p1.y;
  long double squaredLen2 = p2.x * p2.x + p2.y * p2.y;
  long double dot = dotProd(p1, p2);
  long double angle = dot / sqrt(squaredLen1 * squaredLen2);
  if (angle > 1.0L) {
    return 0.0L;
  }
  if (angle < -1.0L) {
    return PI_L;
  }
  return acosl(angle);
}
long double signedArea(vector<Point> &convexPolygon) {
  long long n = convexPolygon.size();
  convexPolygon.push_back(convexPolygon[0]);
  convexPolygon.push_back(convexPolygon[1]);
  long double area = 0.0L;
  for (long long i = (1); i <= (n); i++) {
    area +=
        convexPolygon[i].x * (convexPolygon[i + 1].y - convexPolygon[i - 1].y);
  }
  return area / 2.0L;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  if (false) {
    freopen("A.in", "r", stdin);
    cerr << "Remember to switch INPUT_FILE off before submitting!" << endl
         << endl;
    freopen("A.out", "w", stdout);
  }
  if (false) {
    cerr << "Remember to switch DEBUGING off before submitting!" << endl
         << endl;
  }
  {
    long long w, h, u1, d1, u2, d2;
    cin >> w >> h >> u1 >> d1 >> u2 >> d2;
    if (d1 < d2) {
      swap(u1, u2), swap(d1, d2);
    }
    long long total = h * (h + 1) / 2;
    long long t1 = (d1 - 1) * d1 / 2;
    long long t2 = (d2 - 1) * d2 / 2;
    long long gain = total - t1;
    w += gain;
    if (w < u1) {
      w = u1;
    }
    w -= u1;
    gain = t1 - t2;
    w += gain;
    if (w < u2) {
      w = u2;
    }
    w -= u2;
    cout << w + t2 << endl;
  }
  if (false) {
    system("gnome-open A.in");
    system("gnome-open A.correct");
    system("gnome-open A.out");
    fstream myAns("A.out");
    fstream correctAns("A.correct");
    string myLine, correctLine;
    long long lineIndex = 1;
    bool moreMyAns, moreCorrectAns;
    moreMyAns = (bool)getline(myAns, myLine);
    moreCorrectAns = (bool)getline(correctAns, correctLine);
    while (moreMyAns && moreCorrectAns) {
      cerr << lineIndex++ << "\t" << (myLine == correctLine ? "ok" : "WRONG")
           << endl;
      moreMyAns = (bool)getline(myAns, myLine);
      moreCorrectAns = (bool)getline(correctAns, correctLine);
    }
    if (moreMyAns) {
      cerr << "ERROR: My answer is too long! Excessive lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << myLine << endl;
      } while (getline(myAns, myLine));
    } else if (moreCorrectAns) {
      cerr << "ERROR: My answer is too short! Missing lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << correctLine << endl;
      } while (getline(correctAns, correctLine));
    }
    myAns.flush();
    myAns.close();
    correctAns.flush();
    correctAns.close();
  }
  return 0;
}
