#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
struct fwk {
  long long b[200105];
  int n;
  void init(int sz) { n = sz; }
  void update(int x, int v) {
    for (int i = x; i <= n; i += i & -i) {
      b[i] += v;
    }
  }
  long long query(int x) {
    long long ret = 0;
    for (; x > 0; ret += b[x], x -= x & -x)
      ;
    return ret;
  }
  long long qy(int l, int r) { return query(r) - query(l - 1); }
} fc[2], fs[2];
int l[200105], r[200105];
vector<int> ls[200105], rs[200105];
void fmain(int tid) {
  scanf("%d%d", &n, &m);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d%d", l + i, r + i);
    ls[l[i]].push_back(i);
    rs[r[i]].push_back(i);
  }
  set<int> all[2];
  for (int(i) = 0; (i) < (int)(2); (i)++) {
    fc[i].init(m);
    fs[i].init(m);
  }
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    fc[i & 1].update((i + 1) / 2, 1);
    fs[i & 1].update((i + 1) / 2, i);
    all[i & 1].insert(i);
  }
  long long ans = 0;
  multiset<int> open[2];
  int L = 1;
  for (int(rg) = 1; (rg) <= (int)(m); (rg)++) {
    for (int id : ls[rg]) {
      open[l[id] & 1].insert(l[id]);
    }
    int lg = L;
    if (!open[(rg & 1) ^ 1].empty()) {
      lg = max(lg, *open[(rg & 1) ^ 1].rbegin() + 1);
    }
    int notSameParityR = rg - 1;
    for (int(par) = 0; (par) < (int)(2); (par)++)
      if (!open[par].empty()) {
        int tmp = *open[par].begin();
        if (par == (rg & 1)) {
          notSameParityR = min(notSameParityR, tmp - 1);
        } else
          notSameParityR = -1;
      }
    for (int(par) = 0; (par) < (int)(2); (par)++) {
      int x = lg, y = rg;
      if (par != (rg & 1)) y = min(y, notSameParityR);
      while (x <= y && (x & 1) != par) x++;
      while (x <= y && (y & 1) != par) y--;
      if (y < x) continue;
      x = (x + 1) / 2;
      y = (y + 1) / 2;
      long long cnt = fc[par].qy(x, y);
      long long ss = fs[par].qy(x, y);
      ans += (long long)(rg + 1) * cnt - ss;
    }
    for (int id : rs[rg]) {
      open[l[id] & 1].erase(open[l[id] & 1].find(l[id]));
      if ((r[id] - l[id] + 1) % 2 == 0) L = max(L, l[id] + 1);
      while (1) {
        auto it = all[(rg & 1) ^ 1].lower_bound(l[id]);
        if (it == all[(rg & 1) ^ 1].end()) break;
        if (*it > r[id]) break;
        int x = *it;
        fc[x & 1].update((x + 1) / 2, -1);
        fs[x & 1].update((x + 1) / 2, -x);
        all[(rg & 1) ^ 1].erase(x);
      }
    }
  }
  set<int> st;
  vector<int> nn(m + 1, 0);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    for (int j : ls[i]) st.insert(j);
    if (st.empty()) nn[i] = 1;
    for (int j : rs[i]) st.erase(j);
  }
  long long cc = 0;
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    if (nn[i])
      cc++;
    else
      cc = 0;
    ans -= cc * (cc + 1) / 2;
  }
  printf("%lld\n", ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
