Butler Ostin wants to show Arkady that rows of odd number of fountains are beautiful, while rows of even number of fountains are not.

The butler wants to show Arkady n gardens. Each garden is a row of m cells, the i-th garden has one fountain in each of the cells between li and ri inclusive, and there are no more fountains in that garden. The issue is that some of the gardens contain even number of fountains, it is wrong to show them to Arkady.

Ostin wants to choose two integers a ≤ b and show only part of each of the gardens that starts at cell a and ends at cell b. Of course, only such segments suit Ostin that each garden has either zero or odd number of fountains on this segment. Also, it is necessary that at least one garden has at least one fountain on the segment from a to b.

Help Ostin to find the total length of all such segments, i.e. sum up the value (b - a + 1) for each suitable pair (a, b).

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 2·105) — the number of gardens and the length of each garden.

n lines follow. The i-th of these lines contains two integers li and ri (1 ≤ li ≤ ri ≤ m) — the bounds of the segment that contains fountains in the i-th garden.

Output

Print one integer: the total length of all suitable segments.

Examples

Input

1 5
2 4


Output

23


Input

3 6
2 4
3 6
4 4


Output

19

Note

In the first example the following pairs suit Ostin: (a, b): (1, 2), (1, 4), (1, 5), (2, 2), (2, 4), (2, 5), (3, 3), (4, 4), (4, 5).

In the second example the following pairs suit Ostin: (a, b): (1, 2), (1, 5), (2, 2), (2, 5), (3, 3), (4, 4), (4, 6), (5, 5), (6, 6).
#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x >= 10) write(x / 10);
  putchar('0' + x % 10);
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
inline void writep(long long x) {
  write(x);
  putchar(' ');
}
inline unsigned long long rnd() {
  return ((unsigned long long)rand() << 30 ^ rand()) << 4 | rand() % 4;
}
const int N = 2e5 + 5;
struct info {
  int l, r;
  bool operator<(const info &rhs) const { return r < rhs.r; }
} a[N];
int cnt[3][N << 2];
long long sum[3][N << 2];
bool lazy[3][N << 2];
void upd(int k) {
  for (int i = (int)(0); i <= (int)(2); i++) {
    sum[i][k] = sum[i][k << 1] + sum[i][k << 1 | 1];
    cnt[i][k] = cnt[i][k << 1] + cnt[i][k << 1 | 1];
  }
}
void buildtree(int k, int l, int r) {
  if (l == r) {
    sum[l & 1][k] = sum[2][k] = l - 1;
    cnt[l & 1][k] = cnt[2][k] = 1;
    return;
  }
  int mid = l + r >> 1;
  buildtree(k << 1, l, mid);
  buildtree(k << 1 | 1, mid + 1, r);
  upd(k);
}
void add(int k, int d) {
  if (cnt[d][k]) {
    sum[2][k] -= sum[d][k];
    sum[d][k] = 0;
    cnt[2][k] -= cnt[d][k];
    cnt[d][k] = 0;
    lazy[d][k] = 1;
  }
  if (d == 2) {
    for (int i = (int)(0); i <= (int)(1); i++) sum[i][k] = cnt[i][k] = 0;
  }
}
void pushdown(int k) {
  if (lazy[2][k]) {
    for (int i = (int)(0); i <= (int)(1); i++) {
      sum[i][k << 1] = sum[i][k << 1 | 1] = 0;
      cnt[i][k << 1] = cnt[i][k << 1 | 1] = 0;
    }
    add(k << 1, 2);
    add(k << 1 | 1, 2);
    lazy[0][k] = lazy[1][k] = lazy[2][k] = 0;
  }
  for (int i = (int)(0); i <= (int)(1); i++)
    if (lazy[i][k]) {
      add(k << 1, i);
      add(k << 1 | 1, i);
      lazy[i][k] = 0;
    }
}
void change(int k, int l, int r, int L, int R, int d) {
  if (L > R) return;
  if (l >= L && r <= R) {
    add(k, d);
    return;
  }
  pushdown(k);
  int mid = l + r >> 1;
  if (L <= mid) change(k << 1, l, mid, L, R, d);
  if (R > mid) change(k << 1 | 1, mid + 1, r, L, R, d);
  upd(k);
}
long long find(int k, int l, int r, int L, int R, int d) {
  if (L > R) return 0;
  if (l >= L && r <= R) return sum[d][k];
  pushdown(k);
  int mid = l + r >> 1;
  if (R <= mid) return find(k << 1, l, mid, L, R, d);
  if (L > mid) return find(k << 1 | 1, mid + 1, r, L, R, d);
  return find(k << 1, l, mid, L, R, d) + find(k << 1 | 1, mid + 1, r, L, R, d);
}
int query(int k, int l, int r, int L, int R, int d) {
  if (L > R) return 0;
  if (l >= L && r <= R) return cnt[d][k];
  pushdown(k);
  int mid = l + r >> 1;
  if (R <= mid) return query(k << 1, l, mid, L, R, d);
  if (L > mid) return query(k << 1 | 1, mid + 1, r, L, R, d);
  return query(k << 1, l, mid, L, R, d) +
         query(k << 1 | 1, mid + 1, r, L, R, d);
}
set<pair<int, int> > s[2];
vector<pair<int, int> > v[N];
int b[N];
long long S(int l, int r) { return (long long)(l + r) * (r - l + 1) / 2; }
int main() {
  int n = read(), m = read();
  for (int i = (int)(1); i <= (int)(n); i++) a[i].l = read(), a[i].r = read();
  sort(a + 1, a + n + 1);
  for (int i = (int)(1); i <= (int)(n); i++) {
    v[a[i].l].push_back(make_pair(i, 1));
    v[a[i].r].push_back(make_pair(i, -1));
  }
  buildtree(1, 1, m);
  long long ans = 0;
  for (int i = (int)(1); i <= (int)(m); i++) {
    for (auto x : v[i])
      if (x.second == 1) {
        s[a[x.first].l % 2].insert(make_pair(-a[x.first].l, x.first));
      }
    int op = i % 2, l = 1;
    if (s[0].size() || s[1].size()) {
      long long mjn = 0;
      int sana = 0;
      if (s[!op].size()) {
        pair<int, int> t = *s[!op].begin();
        l = -t.first;
        mjn = find(1, 1, m, l, i, i % 2);
        sana = query(1, 1, m, l, i, i % 2);
      } else {
        pair<int, int> t = *(--s[op].end());
        l = -t.first;
        mjn = find(1, 1, m, l, i, i % 2) + find(1, 1, m, 1, l - 1, 2);
        sana = query(1, 1, m, l, i, i % 2) + query(1, 1, m, 1, l - 1, 2);
      }
      ans += (long long)sana * i - mjn;
    } else {
      long long mjn = find(1, 1, m, l, i, 2);
      int sana = query(1, 1, m, l, i, 2);
      ans += (long long)sana * i - mjn;
    }
    for (auto x : v[i])
      if (x.second == -1) {
        if ((a[x.first].r - a[x.first].l) % 2)
          change(1, 1, m, 1, a[x.first].l, 2);
        change(1, 1, m, a[x.first].l, a[x.first].r, !(a[x.first].r % 2));
        pair<int, int> ssw = make_pair(-a[x.first].l, x.first);
        s[a[x.first].l % 2].erase(ssw);
      }
  }
  for (int i = (int)(1); i <= (int)(n); i++) b[a[i].l]++, b[a[i].r + 1]--;
  for (int i = (int)(1); i <= (int)(m); i++) b[i] += b[i - 1];
  int pre = 0;
  for (int i = (int)(1); i <= (int)(m); i++) {
    if (!b[i]) ans -= S(1, i - pre);
    if (b[i]) pre = i;
  }
  cout << ans;
}
