#include <bits/stdc++.h>
int read();
int n;
const long long inf = 1e10;
long long d[300005], k, l, r;
std::vector<std::pair<int, long long>> act[300005];
std::set<std::pair<std::pair<long long, long long>, int>> S;
void work(std::pair<std::pair<long long, long long>, int> p, long long l,
          long long r, int i) {
  long long L = p.first.first;
  long long R = p.first.second;
  if (l > R || r < L) return;
  act[i].push_back(std::make_pair(p.second, -(R - L + 1)));
  S.erase(p);
  if (L >= l && R <= r) return;
  if (L <= l && r <= R) {
    int l1 = L, r1 = l - 1, l2 = r + 1, r2 = R;
    if (l1 <= r1) {
      act[i].push_back(std::make_pair(p.second, (r1 - l1 + 1)));
      S.insert(std::make_pair(std::make_pair(l1, r1), p.second));
    }
    if (l2 <= r2) {
      act[i].push_back(std::make_pair(p.second, (r2 - l2 + 1)));
      S.insert(std::make_pair(std::make_pair(l2, r2), p.second));
    }
    return;
  }
  if (L < l) R = std::min(R, l - 1);
  if (R > r) L = std::max(r + 1, L);
  act[i].push_back(std::make_pair(p.second, (R - L + 1)));
  S.insert(std::make_pair(std::make_pair(L, R), p.second));
}
void ins(long long l, long long r, int i) {
  std::stack<std::pair<std::pair<long long, long long>, int>> stk;
  auto p = S.lower_bound(std::make_pair(std::make_pair(l, -inf), -inf));
  stk.push(*std::prev(p));
  while ((*p).first.first <= r) {
    stk.push(*p);
    p++;
  }
  while (!stk.empty()) {
    auto P = stk.top();
    stk.pop();
    work(P, l, r, i);
  }
  S.insert(std::make_pair(std::make_pair(l, r), i));
  act[i].push_back(std::make_pair(i, r - l + 1));
}
int check(long long x, int flag) {
  std::memset(d, 0, sizeof(d));
  int l = 1;
  long long sum = 0, sumw = 0, sumS = 0, ans = 0, ans2 = 0;
  for (int i = 1; i <= n; ++i) {
    for (auto p : act[i]) {
      int pt = p.first;
      long long det = p.second;
      d[pt] += det;
      sumS += det * pt;
      if (l <= pt) {
        sum += det;
        sumw += det * pt;
      }
    }
    while (l <= i && sum >= x) {
      sum -= d[l];
      sumw -= d[l] * l;
      l++;
    }
    ans += l - 1;
    ans2 += sumS - (sumw - sum * (l - 1));
  }
  if (flag) {
    printf("%lld", ans2 - x * (ans - k));
  }
  return ans >= k;
}
signed main() {
  scanf("%d%lld", &n, &k);
  S.insert(std::make_pair(std::make_pair(0, 0), 0));
  S.insert(std::make_pair(std::make_pair(inf, inf), 0));
  for (int i = 1; i <= n; ++i) {
    scanf("%lld%lld", &l, &r);
    r--;
    ins(l, r, i);
  }
  long long l = 0, r = 1e9, ans = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid, 0)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  check(ans, 1);
  return 0;
}
int read() {
  char c = getchar();
  int flag = 1;
  int x = 0;
  while (c < '0' || c > '9') {
    if (c == '-') flag = -flag;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * flag;
}
