#include <bits/stdc++.h>
using namespace std;
struct Fenwick {
  int len;
  vector<long long> tree;
  Fenwick() {
    len = 2e5;
    tree = vector<long long>(len + 1);
  }
  void update(int index, int val) {
    while (index <= len) {
      tree[index] += val;
      index += index & (-index);
    }
  }
  long long sum(int index) {
    long long ans = 0;
    while (index > 0) {
      ans += tree[index];
      index -= index & (-index);
    }
    return ans;
  }
  long long sum(int leftIndex, int rightIndex) {
    return sum(rightIndex) - sum(leftIndex - 1);
  }
};
const int len = 2e5 + 1;
vector<int> founleft[len], founright[len];
Fenwick tree[2][2];
set<int> nodes[2];
int main() {
  int Test = 1;
  for (int test = 1; test <= Test; ++test) {
    vector<int> left(len), right(len);
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; ++i) {
      scanf("%d %d", &left[i], &right[i]);
      founleft[left[i]].push_back(i);
      founright[right[i]].push_back(i);
    }
    for (int i = 1; i <= m; ++i) {
      tree[i % 2][0].update((i + 1) / 2, 1);
      tree[i % 2][1].update((i + 1) / 2, i);
      nodes[i % 2].insert(i);
    }
    long long ans = 0;
    multiset<int> running[2];
    int minStart = 1;
    for (int cur = 1; cur <= m; ++cur) {
      for (int i : founleft[cur]) {
        running[left[i] % 2].insert(left[i]);
      }
      int start = minStart;
      if (!running[1 - cur % 2].empty()) {
        int last = *(--running[1 - cur % 2].end());
        start = max(start, last + 1);
      }
      int end = cur - 1;
      for (int par = 0; par < 2; ++par) {
        if (!running[par].empty()) {
          int strt = (*(running[par].begin()));
          if (strt % 2 == cur % 2) {
            end = min(end, strt - 1);
          } else {
            end = -1;
          }
        }
      }
      for (int par = 0; par < 2; ++par) {
        int from = start;
        int to = cur;
        if (par != cur % 2) {
          to = min(to, end);
        }
        if (from <= to && from % 2 != par) {
          from++;
        }
        if (from <= to && to % 2 != par) {
          to--;
        }
        if (from <= to) {
          long long cnt = tree[par][0].sum((from + 1) / 2, (to + 1) / 2);
          long long dist = tree[par][1].sum((from + 1) / 2, (to + 1) / 2);
          ans += (cur + 1) * cnt - dist;
        }
      }
      for (int i : founright[cur]) {
        running[left[i] % 2].erase(running[left[i] % 2].find(left[i]));
        if ((right[i] - left[i] + 1) % 2 == 0) {
          minStart = max(minStart, left[i] + 1);
        }
        auto iter = nodes[1 - cur % 2].lower_bound(left[i]);
        while (iter != nodes[1 - cur % 2].end() && *iter <= right[i]) {
          int val = *iter;
          tree[val % 2][0].update((val + 1) / 2, -1);
          tree[val % 2][1].update((val + 1) / 2, -val);
          nodes[1 - cur % 2].erase(iter);
          iter = nodes[1 - cur % 2].lower_bound(left[i]);
        }
      }
    }
    long long cnt = 0;
    int fnt = 0;
    for (int i = 1; i <= m; ++i) {
      fnt += founleft[i].size();
      if (fnt == 0) {
        cnt++;
        ans -= (cnt * (cnt + 1)) / 2;
      } else {
        cnt = 0;
      }
      fnt -= founright[i].size();
    }
    cout << ans << endl;
  }
  return 0;
}
