#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxn = 200100;
int n, m;
pair<int, int> a[maxn + 5];
int posl[maxn + 5], posr[maxn + 5];
long long ans;
struct node {
  node *c[2];
  long long sum;
  int cnt;
  bool label;
  node() : sum(0), cnt(0), label(0) { memset(c, 0, sizeof c); }
  void update() {
    sum = 0;
    cnt = 0;
    for (int i = (0), i_end_ = (2); i < i_end_; ++i)
      if (c[i]) sum += c[i]->sum, cnt += c[i]->cnt;
  }
  void flag_label() {
    label = 1;
    sum = 0;
    cnt = 0;
  }
  void push_down() {
    if (label) {
      for (int i = (0), i_end_ = (2); i < i_end_; ++i) c[i]->flag_label();
      label = 0;
    }
  }
};
const int max0 = 100000;
node *nd_pool;
int nd_res = 0;
inline node *newnode() {
  if (!nd_res) nd_pool = new node[max0], nd_res = max0;
  return nd_pool + (--nd_res);
}
int seg_x, seg_y;
int seg_od;
void build(node *&rt, int l, int r) {
  rt = newnode();
  if (r - l <= 1) {
    if ((l & 1) == seg_od)
      rt->sum = l, rt->cnt = 1;
    else
      rt->sum = 0, rt->cnt = 0;
    return;
  }
  int mid = (l + r) >> 1;
  build(rt->c[0], l, mid);
  build(rt->c[1], mid, r);
  rt->update();
}
void add(node *rt, int l, int r) {
  if (seg_x <= l && r <= seg_y) {
    rt->flag_label();
    return;
  }
  int mid = (l + r) >> 1;
  rt->push_down();
  if (seg_x < mid) add(rt->c[0], l, mid);
  if (seg_y > mid) add(rt->c[1], mid, r);
  rt->update();
}
long long seg_sum;
int seg_cnt;
void query(node *rt, int l, int r) {
  if (seg_x <= l && r <= seg_y) {
    seg_sum += rt->sum, seg_cnt += rt->cnt;
    return;
  }
  int mid = (l + r) >> 1;
  rt->push_down();
  if (seg_x < mid) query(rt->c[0], l, mid);
  if (seg_y > mid) query(rt->c[1], mid, r);
}
node *rt;
inline void work(int odl, int odr) {
  int ptrl = 0, ptrr = 0;
  multiset<int> limr, liml;
  limr.insert(0), liml.insert(m);
  rt = NULL;
  seg_od = odl;
  build(rt, 0, m);
  for (int i = odr; i < m; i += 2) {
    while (ptrl < n && a[posl[ptrl]].first <= i) {
      if (odl != odr) liml.insert(a[posl[ptrl]].first);
      if ((a[posl[ptrl]].first ^ odr) & 1) {
        limr.insert(a[posl[ptrl]].first);
      }
      ++ptrl;
    }
    while (ptrr < n && a[posr[ptrr]].second <= i) {
      if (odl != odr) liml.erase(liml.find(a[posr[ptrr]].first));
      if ((a[posr[ptrr]].first ^ odr) & 1) {
        limr.erase(limr.find(a[posr[ptrr]].first));
      }
      if (!((a[posr[ptrr]].second ^ a[posr[ptrr]].first) & 1)) {
        limr.insert(a[posr[ptrr]].first);
      }
      if (!((a[posr[ptrr]].second ^ odl) & 1)) {
        seg_x = a[posr[ptrr]].first;
        seg_y = a[posr[ptrr]].second;
        add(rt, 0, m);
      }
      ++ptrr;
    }
    seg_x = *--limr.end(), seg_y = *liml.begin();
    if (ptrl == ptrr) {
      if (!ptrr)
        chkmin(seg_y, 0);
      else
        chkmin(seg_y, a[posr[ptrr - 1]].second);
    }
    chkmin(seg_y, i + 1);
    if (seg_x < seg_y) {
      seg_sum = 0;
      seg_cnt = 0;
      query(rt, 0, m);
      ans += (long long)seg_cnt * (i + 1) - seg_sum;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0), i_end_ = (n); i < i_end_; ++i)
    scanf("%d%d", &a[i].first, &a[i].second), --a[i].first,
        posl[i] = posr[i] = i;
  sort(posl, posl + n,
       [&](int first, int second) { return a[first].first < a[second].first; });
  sort(posr, posr + n, [&](int first, int second) {
    return a[first].second < a[second].second;
  });
  for (int odl = (0), odl_end_ = (2); odl < odl_end_; ++odl)
    for (int odr = (0), odr_end_ = (2); odr < odr_end_; ++odr) {
      work(odl, odr);
    }
  cout << ans << endl;
  return 0;
}
