#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v);
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream& operator>>(istream& cin, pair<A, B>& p) {
  cin >> p.first;
  return cin >> p.second;
}
mt19937 rng(steady_clock::now().time_since_epoch().count());
void usaco(string filename) {
#pragma message("be careful, freopen may be wrong")
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
const long long mod = 1000000007;
template <typename num_t>
struct segtree {
  int n, depth;
  vector<num_t> tree, lazy;
  void init(int second, long long* arr) {
    n = second;
    tree = vector<num_t>(4 * second, 0);
    lazy = vector<num_t>(4 * second, 0);
    init(0, 0, n - 1, arr);
  }
  num_t init(int i, int l, int r, long long* arr) {
    if (l == r) return tree[i] = arr[l];
    int mid = (l + r) / 2;
    num_t a = init(2 * i + 1, l, mid, arr),
          b = init(2 * i + 2, mid + 1, r, arr);
    return tree[i] = a.op(b);
  }
  void update(int l, int r, num_t v) {
    if (l > r) return;
    update(0, 0, n - 1, l, r, v);
  }
  num_t update(int i, int tl, int tr, int ql, int qr, num_t v) {
    eval_lazy(i, tl, tr);
    if (tl > tr || tr < ql || qr < tl) return tree[i];
    if (ql <= tl && tr <= qr) {
      lazy[i] = lazy[i].val + v.val;
      eval_lazy(i, tl, tr);
      return tree[i];
    }
    if (tl == tr) return tree[i];
    int mid = (tl + tr) / 2;
    num_t a = update(2 * i + 1, tl, mid, ql, qr, v),
          b = update(2 * i + 2, mid + 1, tr, ql, qr, v);
    return tree[i] = a.op(b);
  }
  num_t query(int l, int r) {
    if (l > r) return num_t::null_v;
    return query(0, 0, n - 1, l, r);
  }
  num_t query(int i, int tl, int tr, int ql, int qr) {
    eval_lazy(i, tl, tr);
    if (ql <= tl && tr <= qr) return tree[i];
    if (tl > tr || tr < ql || qr < tl) return num_t::null_v;
    int mid = (tl + tr) / 2;
    num_t a = query(2 * i + 1, tl, mid, ql, qr),
          b = query(2 * i + 2, mid + 1, tr, ql, qr);
    return a.op(b);
  }
  void eval_lazy(int i, int l, int r) {
    tree[i] = tree[i].lazy_op(lazy[i], (r - l + 1));
    if (l != r) {
      lazy[i * 2 + 1] = lazy[i].val + lazy[i * 2 + 1].val;
      lazy[i * 2 + 2] = lazy[i].val + lazy[i * 2 + 2].val;
    }
    lazy[i] = num_t();
  }
};
struct max_t {
  long long val;
  static const long long null_v = -92233720368547757LL;
  max_t() : val(0) {}
  max_t(long long v) : val(v) {}
  max_t op(max_t& other) { return max_t(max(val, other.val)); }
  max_t lazy_op(max_t v, int size) { return max_t(val + v.val); }
};
long long n, m, k, q, Q, T, l, r, x, y, z;
long long a[1000005];
long long b[1000005];
long long c[1000005];
string second, t;
long long ans = 0;
pair<int, int> locs[300005];
long long lsum[300005], rsum[300005];
segtree<max_t> lbest, rbest;
set<int> pts;
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  };
  cin >> n >> k;
  for (long long i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (long long i = 0; i < n - 1; i++)
    locs[i] = make_pair(a[i + 1] - a[i], i + 1);
  sort(locs, locs + (n - 1));
  reverse(locs, locs + (n - 1));
  for (long long i = 0; i < n; i++) b[i] = k - b[i];
  long long second = 0;
  for (long long i = 0; i < n; i++) {
    second += b[i];
    lsum[i] = second;
  }
  second = 0;
  for (long long i = n - 1; i >= 0; i--) {
    second += b[i];
    rsum[i] = second;
  }
  lbest.init(n, lsum);
  rbest.init(n, rsum);
  pts.insert(0);
  pts.insert(n);
  int pt = 0;
  for (long long i = 0; i < n - 1; i++) {
    long long val = locs[i].first;
    int loc = locs[i].second;
    while (pt < i && locs[pt].first != locs[i].first) {
      pts.insert(locs[pt].second);
      ++pt;
    }
    auto pt = pts.upper_bound(loc);
    int ri = *pt;
    int le = *(--pt);
    long long rb = lbest.query(loc, ri - 1).val;
    rb -= lsum[loc - 1];
    long long lb = rbest.query(le, loc - 1).val;
    lb -= rsum[loc];
    ans = max(ans, lb + rb - val * val);
  }
  for (long long i = 0; i < n; i++) ans = max(ans, b[i]);
  cout << ans << endl;
}
