#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n, K, a[maxn], b[maxn], d[maxn];
map<int, int> s;
map<int, int>::iterator it;
vector<pair<int, int> > del[maxn];
pair<long long, long long> ans;
void split(int x) {
  it = s.upper_bound(x), it--;
  if (it->first != x) s[x] = it->second;
}
map<int, int>::iterator nxt(map<int, int>::iterator it) {
  it++;
  return it;
}
pair<long long, long long> check(int Val) {
  memset(d, 0, sizeof(d));
  int l = 1;
  long long sumf = 0, sums = 0, nows = 0, nowc = 0;
  for (int r = 1; r <= n; r++) {
    for (int i = 0; i < del[r].size(); i++) {
      pair<int, int> x = del[r][i];
      d[x.first] += x.second;
      if (x.first <= l)
        nowc += x.second, nows += 1ll * (l - x.first) * x.second;
    }
    while (nowc > Val) nows += nowc, nowc += d[++l];
    sumf += l - 1, sums += nows;
  }
  return make_pair(sumf, sums);
}
int main() {
  scanf("%d%d", &n, &K);
  s[1e9 + 1] = 0, s[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i], &b[i]), a[i]++;
    split(a[i]);
    split(b[i] + 1);
    for (it = s.lower_bound(a[i]); it->first <= b[i];) {
      del[i].push_back(make_pair(it->second + 1, nxt(it)->first - it->first));
      map<int, int>::iterator it1 = nxt(it);
      s.erase(it);
      it = it1;
    }
    del[i].push_back(make_pair(i + 1, -(b[i] - a[i] + 1)));
    s[a[i]] = i;
  }
  int l = 0, r = 1e9, ans1 = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    pair<long long, long long> x = check(mid);
    if (x.first < K)
      ans = x, ans1 = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans.second + 1ll * ans1 * (K - ans.first));
  return 0;
}
