#include <bits/stdc++.h>
long long read() {
  long long r = 0, t = 1, c = getchar();
  while (c < '0' || c > '9') {
    t = c == '-' ? -1 : 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    r = (r << 3) + (r << 1) + (c ^ 48);
    c = getchar();
  }
  return r * t;
}
const long long N = 1 << 20 | 10;
long long n, m, k;
long long l[N], r[N];
long long q[N];
long long L, R;
std::map<std::pair<long long, long long>, long long> o;
std::vector<std::pair<long long, long long> > D[N], rD[N];
void init() {
  for (long long i = (n), end_i = (1); i >= end_i; i--) {
    auto it = o.lower_bound({l[i], 0});
    if (it != o.begin()) {
      it--;
      if (it->first.second > l[i]) {
        auto It = *it;
        o.erase(it);
        o[{It.first.first, l[i]}] = o[{l[i], It.first.second}] = It.second;
      }
      it = o.lower_bound({l[i], 0});
    }
    while (it != o.end() && it->first.first < r[i]) {
      auto It = *it;
      it = o.erase(it);
      if (It.first.second > r[i]) o[{r[i], It.first.second}] = It.second;
      D[i].push_back(
          {It.second, std::min(r[i], It.first.second) - It.first.first});
    }
    o[{l[i], r[i]}] = i;
  }
  for (long long i = (1), end_i = (n); i <= end_i; i++)
    for (auto j : D[i]) rD[j.first].push_back({i, j.second});
}
long long ans;
long long solve(long long p) {
  long long s = 0;
  long long Ans = 0;
  ans = 0;
  for (long long i = n + 1, j = n; i >= 1;) {
    if (j >= i && s >= p) {
      Ans += s;
      s -= r[j] - l[j];
      for (auto k : rD[j])
        if (i <= k.first) s += k.second;
      j--;
    } else {
      q[i] = j + 1;
      ans += Ans;
      i--;
      s += r[i] - l[i];
      Ans += (r[i] - l[i]) * (n - j);
      for (auto k : D[i]) {
        if (j >= k.first) s -= k.second;
        Ans -= k.second * std::min(n - j, n - k.first + 1);
      }
    }
  }
  long long Q = 0;
  for (long long i = (1), end_i = (n); i <= end_i; i++) Q += n - q[i] + 1;
  return Q;
}
signed main() {
  n = read();
  k = read();
  for (long long i = (1), end_i = (n); i <= end_i; i++) {
    l[i] = read();
    r[i] = read();
  }
  init();
  L = 0;
  R = 1000000000;
  while (L < R) {
    long long mid = (L + R) >> 1;
    if (solve(mid) <= k)
      R = mid;
    else
      L = mid + 1;
  }
  solve(R);
  ans += (R - 1) * k;
  for (long long i = (n), end_i = (1); i >= end_i; i--)
    ans -= (R - 1) * (n - q[i] + 1);
  printf("%I64d\n", ans);
  return 0;
}
