#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int mod1 = 998244353;
void fastscan(long long int &number) {
  bool negative = false;
  register int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
bool isprime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
bool checkisTree(long long int degree[], long long int n) {
  long long int deg_sum = 0;
  for (long long int i = 0; i < n; i++) deg_sum += degree[i];
  return (2 * (n - 1) == deg_sum);
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int findS(long long int s) {
  int l = 1, r = (s / 2) + 1;
  while (l <= r) {
    long long int mid = (l + r) / 2;
    long long int sum = mid * (mid + 1) / 2;
    if (sum == s)
      return mid;
    else if (sum > s)
      r = mid - 1;
    else
      l = mid + 1;
  }
  return -1;
}
int main() {
  cin.sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  cin.tie(0);
  long long int t = 1;
  while (t--) {
    long long int w, h, u1, h1, u2, h2;
    cin >> w >> h >> u1 >> h1 >> u2 >> h2;
    for (int i = h; i >= 0; i--) {
      w += i;
      if (i == h1) w -= u1;
      if (i == h2) w -= u2;
      w = max((long long int)0, w);
    }
    cout << w;
  }
}
