#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(T& x) {
  x = 0;
  int f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x = f ? -x : x;
}
const int N = 3e5 + 10;
struct Node {
  long long sum, pre, suff;
} p[N << 2];
int n, i, l[N], r[N];
long long ans, a, td[N], d[N], c[N];
void pushup(int root) {
  p[root].sum = p[root << 1].sum + p[root << 1 | 1].sum;
  p[root].pre = max(p[root << 1].pre, p[root << 1].sum + p[root << 1 | 1].pre);
  p[root].suff =
      max(p[root << 1 | 1].suff, p[root << 1].suff + p[root << 1 | 1].sum);
}
void build(int root, int l, int r) {
  if (l == r) {
    p[root].sum = p[root].pre = p[root].suff = c[l];
    return;
  }
  int mid = l + ((r - l) >> 1);
  build(root << 1, l, mid);
  build(root << 1 | 1, mid + 1, r);
  pushup(root);
}
pair<long long, long long> MergePre(const pair<long long, long long>& A,
                                    const pair<long long, long long>& B) {
  pair<long long, long long> res = A;
  res.first += B.first;
  res.second = max(res.second, A.first + B.second);
  return res;
}
pair<long long, long long> queryPre(int root, int l, int r, int L, int R) {
  if (L <= l && r <= R) return make_pair(p[root].sum, p[root].pre);
  int mid = l + ((r - l) >> 1);
  if (L > mid)
    return queryPre(root << 1 | 1, mid + 1, r, L, R);
  else if (R <= mid)
    return queryPre(root << 1, l, mid, L, R);
  else
    return MergePre(queryPre(root << 1, l, mid, L, R),
                    queryPre(root << 1 | 1, mid + 1, r, L, R));
}
pair<long long, long long> MergeSuff(const pair<long long, long long>& A,
                                     const pair<long long, long long>& B) {
  pair<long long, long long> res = B;
  res.first += A.first;
  res.second = max(res.second, A.second + B.first);
  return res;
}
pair<long long, long long> querySuff(int root, int l, int r, int L, int R) {
  if (L <= l && r <= R) return make_pair(p[root].sum, p[root].suff);
  int mid = l + ((r - l) >> 1);
  if (L > mid)
    return querySuff(root << 1 | 1, mid + 1, r, L, R);
  else if (R <= mid)
    return querySuff(root << 1, l, mid, L, R);
  else
    return MergeSuff(querySuff(root << 1, l, mid, L, R),
                     querySuff(root << 1 | 1, mid + 1, r, L, R));
}
int main() {
  read(n), read(a);
  for (i = 1; i <= n; ++i) {
    read(d[i]), read(c[i]);
    td[i] = d[i] - d[i - 1];
    c[i] = a - c[i];
    l[i] = r[i] = i;
    ans = max(ans, c[i]);
  }
  build(1, 1, n);
  for (i = 2; i <= n; ++i) {
    int cur = i;
    while (cur > 1 && td[i] >= td[cur - 1]) cur = l[cur - 1];
    l[i] = cur;
  }
  for (i = n - 1; i >= 1; --i) {
    int cur = i;
    while (cur < n && td[i] >= td[cur + 1]) cur = r[cur + 1];
    r[i] = cur;
  }
  for (i = 2; i <= n; ++i) {
    ans = max(ans, querySuff(1, 1, n, max(l[i] - 1, 1), i - 1).second +
                       queryPre(1, 1, n, i, r[i]).second - 1LL * td[i] * td[i]);
  }
  printf("%lld\n", ans);
  return 0;
}
