#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m;
unsigned long long s1[N];
map<unsigned long long, long long> mp1, mp2;
int s2[N];
long long ans;
unsigned long long RND() {
  static unsigned long long A = 43214621742181ull;
  static unsigned long long B = 78197483241297ull;
  A ^= (A << 1) ^ (B >> 18);
  B ^= (B >> 7) ^ (A << 21);
  return A ^ B;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(n); i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    unsigned long long tmp = RND();
    s1[l + 1] ^= tmp;
    s1[r + 1] ^= tmp;
    s2[l]++;
    s2[r + 1]--;
  }
  for (int i = (int)(1); i <= (int)(m + 1); i++) s2[i] += s2[i - 1];
  for (int i = (int)(1); i <= (int)(m + 1); i++) s1[i] ^= s1[i - 1];
  for (int i = (int)(1); i <= (int)(m + 1); i++) s1[i] ^= s1[i - 1];
  for (int i = (int)(1); i <= (int)(m); i++) {
    ++mp1[s1[i]];
    mp2[s1[i]] += i - 1;
    ans -= 1ll * mp2[s1[i]];
    ans += 1ll * mp1[s1[i]] * i;
  }
  int l = 0;
  for (int i = (int)(1); i <= (int)(m + 1); i++)
    if (i == m + 1 || s2[i]) {
      for (int j = (int)(1); j <= (int)(l); j++) ans -= 1ll * j * (l - j + 1);
      l = 0;
    } else
      ++l;
  printf("%lld\n", ans);
}

### Prompt

Create a solution in cpp for the following problem:

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).

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, m;
unsigned long long s1[N];
map<unsigned long long, long long> mp1, mp2;
int s2[N];
long long ans;
unsigned long long RND() {
  static unsigned long long A = 43214621742181ull;
  static unsigned long long B = 78197483241297ull;
  A ^= (A << 1) ^ (B >> 18);
  B ^= (B >> 7) ^ (A << 21);
  return A ^ B;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(n); i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    unsigned long long tmp = RND();
    s1[l + 1] ^= tmp;
    s1[r + 1] ^= tmp;
    s2[l]++;
    s2[r + 1]--;
  }
  for (int i = (int)(1); i <= (int)(m + 1); i++) s2[i] += s2[i - 1];
  for (int i = (int)(1); i <= (int)(m + 1); i++) s1[i] ^= s1[i - 1];
  for (int i = (int)(1); i <= (int)(m + 1); i++) s1[i] ^= s1[i - 1];
  for (int i = (int)(1); i <= (int)(m); i++) {
    ++mp1[s1[i]];
    mp2[s1[i]] += i - 1;
    ans -= 1ll * mp2[s1[i]];
    ans += 1ll * mp1[s1[i]] * i;
  }
  int l = 0;
  for (int i = (int)(1); i <= (int)(m + 1); i++)
    if (i == m + 1 || s2[i]) {
      for (int j = (int)(1); j <= (int)(l); j++) ans -= 1ll * j * (l - j + 1);
      l = 0;
    } else
      ++l;
  printf("%lld\n", ans);
}

```