#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 200000;
const int MAXLEN = 200000;
const int MAXE = 9 * MAXN + 1;
typedef struct E {
  int t, l, r, by;
} E;
bool operator<(const E &a, const E &b) { return a.t < b.t; }
int n, len;
int a[MAXN], b[MAXN];
E e[MAXE];
int ne;
int smin[4 * MAXN];
int scnt[4 * MAXN];
long long ssum[4 * MAXN];
int slazy[4 * MAXN];
void sapply(int x, int by) {
  smin[x] += by;
  slazy[x] += by;
}
void scalc(int x) {
  smin[x] = min(smin[2 * x + 1], smin[2 * x + 2]);
  scnt[x] = ssum[x] = 0;
  if (smin[2 * x + 1] == smin[x])
    scnt[x] += scnt[2 * x + 1], ssum[x] += ssum[2 * x + 1];
  if (smin[2 * x + 2] == smin[x])
    scnt[x] += scnt[2 * x + 2], ssum[x] += ssum[2 * x + 2];
}
void spush(int x) {
  if (slazy[x] == 0) return;
  sapply(2 * x + 1, slazy[x]);
  sapply(2 * x + 2, slazy[x]);
  slazy[x] = 0;
}
void sinit(int x, int l, int r, int p) {
  slazy[x] = 0;
  if (l == r) {
    smin[x] = 0;
    if (l % 2 == p)
      scnt[x] = 1, ssum[x] = l;
    else
      scnt[x] = 0, ssum[x] = 0;
  } else {
    int m = l + (r - l) / 2;
    sinit(2 * x + 1, l, m, p);
    sinit(2 * x + 2, m + 1, r, p);
    scalc(x);
  }
}
void smod(int x, int l, int r, int L, int R, int BY) {
  if (L <= l && r <= R) {
    sapply(x, BY);
  } else {
    spush(x);
    int m = l + (r - l) / 2;
    if (L <= m) smod(2 * x + 1, l, m, L, R, BY);
    if (m + 1 <= R) smod(2 * x + 2, m + 1, r, L, R, BY);
    scalc(x);
  }
}
void addrange(int tl, int tr, int l, int r) {
  if (l > r) return;
  e[ne].t = tl, e[ne].l = l, e[ne].r = r, e[ne].by = +1, ++ne;
  e[ne].t = tr, e[ne].l = l, e[ne].r = r, e[ne].by = -1, ++ne;
}
pair<int, int> c[MAXN];
int nc;
pair<int, int> d[MAXN];
int nd;
void run() {
  scanf("%d%d", &n, &len);
  for (int i = (0); i < (n); ++i) scanf("%d%d", &a[i], &b[i]), --a[i], --b[i];
  nc = 0;
  for (int i = (0); i < (n); ++i) c[nc++] = make_pair(a[i], b[i]);
  sort(c, c + nc);
  int nnc = 0;
  for (int i = (0); i < (nc); ++i)
    if (nnc == 0 || c[i].first > c[nnc - 1].second + 1)
      c[nnc++] = c[i];
    else
      c[nnc - 1].second = max(c[nnc - 1].second, c[i].second);
  nc = nnc;
  nd = 0;
  if (c[0].first > 0) d[nd++] = make_pair(0, c[0].first - 1);
  for (int i = (0); i < (nc - 1); ++i)
    d[nd++] = make_pair(c[i].second + 1, c[i + 1].first - 1);
  if (c[nc - 1].second < len - 1)
    d[nd++] = make_pair(c[nc - 1].second + 1, len - 1);
  long long ret = 0;
  for (int ps = (0); ps < (2); ++ps)
    for (int pt = (0); pt < (2); ++pt) {
      ne = 0;
      sinit(0, 0, len - 1, pt);
      for (int i = (0); i < (n); ++i) {
        if (pt != a[i] % 2) addrange(0, a[i], a[i], b[i]);
        if ((b[i] - a[i] + 1) % 2 == 0) addrange(0, a[i], b[i] + 1, len - 1);
        if (ps != pt) addrange(a[i], b[i] + 1, a[i], b[i]);
        if (ps != b[i] % 2) addrange(a[i], b[i] + 1, b[i] + 1, len - 1);
      }
      sort(e, e + ne);
      int ei = 0;
      int di = 0;
      for (int i = ps; i < len; i += 2) {
        if (di < nd && i >= d[di].first)
          smod(0, 0, len - 1, d[di].first, d[di].second, +1), ++di;
        if (i != 0) smod(0, 0, len - 1, 0, i - 1, +1);
        while (ei < ne && e[ei].t <= i)
          smod(0, 0, len - 1, e[ei].l, e[ei].r, e[ei].by), ++ei;
        if (smin[0] == 0) ret += ssum[0] + scnt[0] - (long long)scnt[0] * i;
      }
    }
  printf("%lld\n", ret);
}
int main() {
  run();
  return 0;
}
