#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, m, l[maxn], r[maxn], sum[maxn];
vector<int> vecl[maxn], vecr[maxn];
multiset<int> sodd, seven;
long long ans;
struct segt {
  long long st1[maxn << 2];
  int st2[maxn << 2];
  bool tag[maxn << 2];
  inline void push_up(int rt) {
    st1[rt] = st1[rt << 1] + st1[rt << 1 | 1];
    st2[rt] = st2[rt << 1] + st2[rt << 1 | 1];
  }
  inline void push_down(int rt) {
    if (tag[rt]) {
      tag[rt << 1] = tag[rt << 1 | 1] = true;
      st1[rt << 1] = st1[rt << 1 | 1] = 0;
      st2[rt << 1] = st2[rt << 1 | 1] = 0;
      tag[rt] = false;
    }
  }
  void build(int rt, int l, int r, int type) {
    if (l == r) {
      if (l % 2 == type) st1[rt] = l, st2[rt] = 1;
      return;
    }
    int mid = l + r >> 1;
    build(rt << 1, l, mid, type);
    build(rt << 1 | 1, mid + 1, r, type);
    push_up(rt);
  }
  inline void build(int type) { build(1, 1, m, type); }
  void modify(int rt, int l, int r, int x, int y) {
    if (l == x && r == y) {
      tag[rt] = true;
      st1[rt] = st2[rt] = 0;
      return;
    }
    push_down(rt);
    int mid = l + r >> 1;
    if (y <= mid)
      modify(rt << 1, l, mid, x, y);
    else if (x > mid)
      modify(rt << 1 | 1, mid + 1, r, x, y);
    else {
      modify(rt << 1, l, mid, x, mid);
      modify(rt << 1 | 1, mid + 1, r, mid + 1, y);
    }
    push_up(rt);
  }
  inline void modify(int x, int y) { modify(1, 1, m, x, y); }
  long long query(int rt, int l, int r, int x, int y, int p) {
    if (l == x && r == y) return st1[rt] - (long long)st2[rt] * p;
    push_down(rt);
    int mid = l + r >> 1;
    if (y <= mid)
      return query(rt << 1, l, mid, x, y, p);
    else if (x > mid)
      return query(rt << 1 | 1, mid + 1, r, x, y, p);
    else
      return query(rt << 1, l, mid, x, mid, p) +
             query(rt << 1 | 1, mid + 1, r, mid + 1, y, p);
  }
  inline long long query(int x, int y, int p) {
    if (x <= y)
      return query(1, 1, m, x, y, p);
    else
      return 0;
  }
} odd, even;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &l[i], &r[i]);
    vecl[l[i]].push_back(r[i]);
    vecr[r[i]].push_back(l[i]);
  }
  for (int i = 1; i <= n; ++i) ++sum[l[i]], --sum[r[i] + 1];
  for (int i = 1; i <= m; ++i) sum[i] += sum[i - 1];
  for (int i = 1; i <= m; ++i)
    if (!sum[i]) {
      int k = 0;
      while (i <= m && !sum[i]) ++i, ++k;
      ans -= ((k + 3ll) * k + 2ll) * k / 6ll;
    }
  odd.build(1);
  even.build(0);
  for (int i = m, end = m; i; --i) {
    for (int j = 0; j < vecl[i].size(); ++j) {
      if (i & 1)
        even.modify(i, vecl[i][j]);
      else
        odd.modify(i, vecl[i][j]);
      if (vecl[i][j] - i & 1) end = min(end, vecl[i][j]);
    }
    int beg = i, endd = end;
    for (int j = 0; j < vecr[i].size(); ++j)
      if (i & 1)
        sodd.insert(i);
      else
        seven.insert(i);
    for (int j = 0; j < vecl[i].size(); ++j)
      if (vecl[i][j] & 1)
        sodd.erase(sodd.find(vecl[i][j]));
      else
        seven.erase(seven.find(vecl[i][j]));
    if (i & 1) {
      if (!seven.empty()) endd = min(endd, *seven.begin());
    } else {
      if (!sodd.empty()) endd = min(endd, *sodd.begin());
    }
    if (!seven.empty()) beg = max(beg, *seven.rbegin() + 1);
    if (!sodd.empty()) beg = max(beg, *sodd.rbegin() + 1);
    ans += odd.query(i & 1 ? i : beg, endd, i - 1);
    ans += even.query(i & 1 ? beg : i, endd, i - 1);
  }
  printf("%lld\n", ans);
  return 0;
}
