#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
bool umax(T1 &a, const T2 &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T1, typename T2>
bool umin(T1 &a, const T2 &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
T sqr(T a) {
  return a * a;
}
mt19937 rng(20010709);
const int mod = 1000000007;
const int INF = 1000000001;
struct Node {
  long long max, sum;
  Node(long long value = 0) {
    sum = value;
    this->max = ::max(0LL, value);
  }
};
int n, a;
long long c[300005], d[300005], dp[300005], costSum[300005], diff[300005];
Node seg[1200005];
vector<int> p;
set<int> s;
long long result;
Node combine(const Node &a, const Node &b);
void build(int v, int l, int r);
Node get(int v, int l, int r, int cl, int cr);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> a;
  for (int i = 1; i <= n; i++) {
    cin >> d[i] >> c[i];
    c[i] = a - c[i];
    diff[i] = d[i] - d[i - 1];
    costSum[i] = costSum[i - 1] + c[i];
  }
  build(1, 0, n);
  p.resize(n - 1);
  iota(p.begin(), p.end(), 2);
  sort(p.begin(), p.end(), [&](int x, int y) {
    if (diff[x] != diff[y]) return diff[x] > diff[y];
    return x < y;
  });
  s.insert(0);
  for (auto i : p) {
    int pos = *prev(s.lower_bound(i));
    dp[i] = get(1, 0, n, pos, i).max - sqr(diff[i]);
    if (pos) umax(dp[i], dp[pos] + costSum[i] - costSum[pos]);
    s.insert(i);
  }
  for (int i = 1; i <= n; i++) umax(result, max(dp[i], c[i]));
  cout << result << "\n";
  return 0;
}
Node combine(const Node &a, const Node &b) {
  Node result;
  result.sum = a.sum + b.sum;
  result.max = max(b.max, b.sum + a.max);
  return result;
}
void build(int v, int l, int r) {
  if (l == r) {
    seg[v] = Node(c[l]);
    return;
  }
  int mid = (l + r) / 2;
  build(v * 2, l, mid);
  build(v * 2 + 1, mid + 1, r);
  seg[v] = combine(seg[v * 2], seg[v * 2 + 1]);
}
Node get(int v, int l, int r, int cl, int cr) {
  if ((l == cl) && (r == cr)) return seg[v];
  Node result;
  int mid = (l + r) / 2;
  if (cl <= mid) result = get(v * 2, l, mid, cl, min(cr, mid));
  if (cr > mid)
    result = combine(result, get(v * 2 + 1, mid + 1, r, max(mid + 1, cl), cr));
  return result;
}
