#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int64;
 
struct BinaryIndexedTree
{
  vector< int64 > data;
 
  BinaryIndexedTree(int sz) : data(++sz, 0) {}
 
 
  int64 sum(int k)
  {
    int64 ret = 0;
    for(++k; k > 0; k -= k & -k) {
      ret += data[k];
    }
    return (ret);
  }
 
  void add(int k, int64 x)
  {
    for(++k; k < data.size(); k += k & -k) {
      data[k] += x;
    }
  }
};
 
 
struct SegmentTree
{
  int sz;
  vector< BinaryIndexedTree > seg;
  vector< vector< int > > beet;
 
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    beet.resize(2 * sz - 1);
  }
 
  void update(int x, int y, int64 z)
  {
    x += sz - 1;
    seg[x].add(lower_bound(begin(beet[x]), end(beet[x]), y) - begin(beet[x]), z);
    while(x > 0) {
      x = (x - 1) >> 1;
      seg[x].add(lower_bound(begin(beet[x]), end(beet[x]), y) - begin(beet[x]), z);
    }
  }
 
  void preupdate(int x, int y, int64 z)
  {
    x += sz - 1;
    beet[x].push_back(y);
    while(x > 0) {
      x = (x - 1) >> 1;
      beet[x].push_back(y);
    }
  }
 
  void build()
  {
    for(int k = beet.size() - 1; k >= 0; k--) {
      sort(begin(beet[k]), end(beet[k]));
      beet[k].erase(unique(begin(beet[k]), end(beet[k])), end(beet[k]));
    }
    for(int k = 0; k < beet.size(); k++) {
      seg.emplace_back(BinaryIndexedTree(beet[k].size()));
    }
  }
 
  void prequery(int a, int b, int x, int y, int k, int l, int r)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      beet[k].push_back(y);
      beet[k].push_back(x);
 
      return;
    }
    prequery(a, b, x, y, 2 * k + 1, l, (l + r) >> 1);
    prequery(a, b, x, y, 2 * k + 2, (l + r) >> 1, r);
  }
 
  int64 query(int a, int b, int x, int y, int k, int l, int r)
  {
    if(a >= r || b <= l) return (0);
    if(a <= l && r <= b) {
      int p = y, q = x;
      y = lower_bound(begin(beet[k]), end(beet[k]), y) - begin(beet[k]);
      x = lower_bound(begin(beet[k]), end(beet[k]), x) - begin(beet[k]);
      return (seg[k].sum(y) - seg[k].sum(x));
    }
    return (query(a, b, x, y, 2 * k + 1, l, (l + r) >> 1) + query(a, b, x, y, 2 * k + 2, (l + r) >> 1, r));
  }
 
  int64 query(int a, int b, int x, int y)
  {
    return (query(a, b, x, y, 0, 0, sz));
  }
 
  void prequery(int a, int b, int x, int y)
  {
    prequery(a, b, x, y, 0, 0, sz);
 
  }
};
 
 
int main()
{
  int N, C, X[100000], Y[100000];
 
  cin >> N >> C;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    --X[i];
  }
  int64 ret = 0LL;
  SegmentTree bit1(100001), bit2(100001);
 
  for(int i = 0; i < N; i++) {
    bit1.prequery(X[i] + 1, 100001, Y[i], 100000);
    bit2.prequery(X[i] + 1, 100001, Y[i], 100000);
    bit2.prequery(X[i] + 1, 100001, 0, Y[i]);
    bit1.prequery(X[i] + 1, 100001, 0, Y[i]);
    bit1.preupdate(X[i], Y[i], 1);
    bit2.preupdate(X[i], Y[i], Y[i]);
  }
  bit1.build();
  bit2.build();
 
  for(int i = 0; i < N; i++) {
    ret += bit1.query(X[i] + 1, 100001, Y[i], 100000) * Y[i] * C;
    ret += bit2.query(X[i] + 1, 100001, Y[i], 100000);
    ret += bit2.query(X[i] + 1, 100001, 0, Y[i]) * C;
    ret += bit1.query(X[i] + 1, 100001, 0, Y[i]) * Y[i];
    bit1.update(X[i], Y[i], 1);
    bit2.update(X[i], Y[i], Y[i]);
  }
  cout << ret << endl;
}

Measured memory_bytes: 164056