#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 1e2;
const int maxs = maxn * 4;
int n, sum[maxn];
multiset<int> ods, evs;
struct node {
  int l, r;
} pl[maxn], pr[maxn];
struct seg {
  int add;
  pair<int, long long> p;
} odtr[maxs], evtr[maxs];
pair<int, long long> getval(seg now) {
  return now.add ? make_pair(0, 0ll) : now.p;
}
pair<int, long long> getsum(pair<int, long long> now1,
                            pair<int, long long> now2) {
  return make_pair(now1.first + now2.first, now1.second + now2.second);
}
void build(int l, int r, int now) {
  if (l == r) {
    if (l & 1) {
      odtr[now].p.first = 1;
      odtr[now].p.second = l;
    } else {
      evtr[now].p.first = 1;
      evtr[now].p.second = l;
    }
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, now << 1);
  build(mid + 1, r, now << 1 | 1);
  odtr[now].p = getsum(getval(odtr[now << 1]), getval(odtr[now << 1 | 1]));
  evtr[now].p = getsum(getval(evtr[now << 1]), getval(evtr[now << 1 | 1]));
}
int ql, qr, v;
void update(seg *tr, int l, int r, int now) {
  if (ql > qr) return;
  if (ql <= l && r <= qr) {
    tr[now].add += v;
    return;
  }
  int mid = (l + r) >> 1;
  if (ql <= mid) update(tr, l, mid, now << 1);
  if (qr > mid) update(tr, mid + 1, r, now << 1 | 1);
  tr[now].p = getsum(getval(tr[now << 1]), getval(tr[now << 1 | 1]));
}
pair<int, long long> query(seg *tr, int l, int r, int now) {
  if (ql > qr) return make_pair(0, 0ll);
  if (ql <= l && r <= qr) return getval(tr[now]);
  if (tr[now].add != 0) return make_pair(0, 0ll);
  int mid = (l + r) >> 1;
  if (qr <= mid) return query(tr, l, mid, now << 1);
  if (ql > mid) return query(tr, mid + 1, r, now << 1 | 1);
  return getsum(query(tr, l, mid, now << 1),
                query(tr, mid + 1, r, now << 1 | 1));
}
long long getans(int x) {
  long long re = 0;
  ql = x, qr = n;
  pair<int, long long> p = query(odtr, 1, n, 1);
  re += p.second - (long long)p.first * (x - 1);
  p = query(evtr, 1, n, 1);
  re += p.second - (long long)p.first * (x - 1);
  return re;
}
bool cmp1(node t1, node t2) { return t1.l < t2.l; }
bool cmp2(node t1, node t2) { return t1.r < t2.r; }
int getint() {
  char ch;
  int b = 1;
  for (ch = getchar(); ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') b = -1;
  int num = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    num = num * 10 + ch - '0';
  return num * b;
}
int main() {
  int m = getint();
  n = getint();
  build(1, n, 1);
  v = 1;
  for (int i = 1; i <= m; i++) {
    ql = pl[i].l = pr[i].l = getint();
    qr = pl[i].r = pr[i].r = getint();
    sum[ql]++;
    sum[qr + 1]--;
    if (pl[i].l & 1)
      update(evtr, 1, n, 1);
    else
      update(odtr, 1, n, 1);
    if (!((pl[i].r - pl[i].l + 1) & 1)) {
      ql = qr + 1, qr = n;
      update(odtr, 1, n, 1);
      update(evtr, 1, n, 1);
    }
  }
  sort(pl + 1, pl + m + 1, cmp1);
  sort(pr + 1, pr + m + 1, cmp2);
  long long ans = 0;
  int now1 = 1, now2 = 1;
  for (int i = 1; i <= n; i++) {
    v = -1;
    while (now1 <= m && pl[now1].l + 1 == i) {
      ql = pl[now1].l;
      qr = pl[now1].r;
      if (pl[now1].l & 1)
        update(evtr, 1, n, 1);
      else
        update(odtr, 1, n, 1);
      if (!((pl[now1].r - pl[now1].l + 1) & 1)) {
        ql = pl[now1].r + 1, qr = n;
        update(odtr, 1, n, 1);
        update(evtr, 1, n, 1);
      }
      if (pl[now1].r & 1)
        ods.insert(pl[now1].r);
      else
        evs.insert(pl[now1].r);
      now1++;
    }
    while (now2 <= m && pr[now2].r + 1 == i) {
      if (pr[now2].r & 1) {
        multiset<int, int>::iterator it =
            find(ods.begin(), ods.end(), pr[now2].r);
        ods.erase(it);
      } else {
        multiset<int, int>::iterator it =
            find(evs.begin(), evs.end(), pr[now2].r);
        evs.erase(it);
      }
      now2++;
    }
    v = 1;
    multiset<int>::iterator it = ods.end();
    int up = 0;
    if (ods.begin() != ods.end()) {
      it--;
      up = *it;
    }
    it = evs.end();
    if (evs.begin() != evs.end()) {
      it--;
      up = max(up, *it);
    }
    if (up) {
      ql = i, qr = up;
      if (i & 1)
        update(evtr, 1, n, 1);
      else
        update(odtr, 1, n, 1);
    }
    if (i & 1)
      ql = *evs.begin();
    else
      ql = *ods.begin();
    qr = n;
    if ((i & 1) && evs.begin() != evs.end()) {
      update(evtr, 1, n, 1);
      update(odtr, 1, n, 1);
    }
    if (!(i & 1) && ods.begin() != ods.end()) {
      update(evtr, 1, n, 1);
      update(odtr, 1, n, 1);
    }
    ans += getans(i);
    v = -1;
    if (up) {
      ql = i, qr = up;
      if (i & 1)
        update(evtr, 1, n, 1);
      else
        update(odtr, 1, n, 1);
    }
    if (i & 1)
      ql = *evs.begin();
    else
      ql = *ods.begin();
    qr = n;
    if ((i & 1) && evs.begin() != evs.end()) {
      update(evtr, 1, n, 1);
      update(odtr, 1, n, 1);
    }
    if (!(i & 1) && ods.begin() != ods.end()) {
      update(evtr, 1, n, 1);
      update(odtr, 1, n, 1);
    }
  }
  for (int i = 1; i <= n; i++) sum[i] += sum[i - 1];
  int zn = 0;
  for (int i = 1; i <= n; i++) {
    if (!sum[i]) {
      zn++;
      ans -= (long long)(1 + zn) * zn / 2;
    } else
      zn = 0;
  }
  printf("%I64d\n", ans);
  return 0;
}
