#include <bits/stdc++.h>
using namespace std;
void rd(int& x) {
  x = 0;
  char ch = 0;
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}
const int MAXN = 300005;
namespace ODT {
map<int, int> s;
int get(int p) { return s.lower_bound(p)->second; }
void split(int p) {
  int t = get(p);
  s[p] = t;
}
pair<map<int, int>::iterator, map<int, int>::iterator> range(int l, int r) {
  split(l), split(r);
  return make_pair(s.find(l), s.find(r));
}
}  // namespace ODT
int n, m, p[MAXN];
vector<pair<int, int> > d[MAXN];
pair<long long, long long> calc(int k) {
  for (int i = 1; i <= n; i++) p[i] = 0;
  int c = 0;
  long long s = 0, cnt = 0, sum = 0;
  for (int i = 1, j = 0; i <= n; i++) {
    for (auto t : d[i]) {
      if (t.first > j) c += t.second, p[t.first] -= t.second;
      s += 1ll * t.second * min(t.first, j);
    }
    while (j < i && c >= k) s += c, c += p[++j];
    cnt += j, sum += s;
  }
  return make_pair(cnt, sum);
}
int main() {
  rd(n), rd(m);
  for (int i = 1; i <= n; i++) {
    int a, b;
    rd(a), rd(b);
    auto border = ODT::range(a, b);
    map<int, int>::iterator op = border.first, cl = border.second;
    d[i].push_back(make_pair(i, b - a));
    while (op != cl) {
      int r = cl->first, x = cl->second;
      ODT::s.erase(cl--);
      if (x) d[i].push_back(make_pair(x, cl->first - r));
    }
    ODT::s[b] = i;
  }
  int l = 0, r = 1e9;
  while (l < r) {
    int mid = (l + r) / 2;
    if (calc(mid).first <= m)
      r = mid;
    else
      l = mid + 1;
  }
  auto res = calc(l);
  printf("%lld\n", res.second + 1ll * (m - res.first) * (l - 1));
  return 0;
}
