#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 300007;
const int MAX = static_cast<int>(1e9 + 7);
int n, K;
int al[MAXN], ar[MAXN];
pair<int, int> op[MAXN * 10];
int opt[MAXN * 10];
int kp;
int vc[MAXN];
void init();
void input();
void work();
pair<long long, long long> check(int tst);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d%d", &n, &K);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &al[i], &ar[i]);
}
void work() {
  map<int, int> s;
  map<int, int>::iterator it, tit, il, ir;
  s.insert(make_pair(0, 0));
  s.insert(make_pair(MAX, 0));
  for (int i = 1; i <= n; ++i) {
    op[++kp] = make_pair(i, ar[i] - al[i]), opt[kp] = i;
    il = --s.upper_bound(al[i]);
    ir = --s.lower_bound(ar[i]);
    if (il == ir) {
      op[++kp] = make_pair(il->second, -(ar[i] - al[i])), opt[kp] = i;
      it = ir;
      ++it;
      if (it->first != ar[i]) s.insert(make_pair(ar[i], il->second));
      if (il->first != al[i])
        s.insert(make_pair(al[i], i));
      else
        il->second = i;
    } else {
      it = il;
      ++it;
      op[++kp] = make_pair(il->second, -(it->first - al[i])), opt[kp] = i;
      if (il->first != al[i])
        s.insert(make_pair(al[i], i));
      else
        il->second = i;
      for (; it != ir; it = tit) {
        tit = it;
        ++tit;
        op[++kp] = make_pair(it->second, -(tit->first - it->first)),
        opt[kp] = i;
        s.erase(it);
      }
      op[++kp] = make_pair(ir->second, -(ar[i] - ir->first)), opt[kp] = i;
      it = ir;
      ++it;
      if (it->first != ar[i]) s.insert(make_pair(ar[i], ir->second));
      s.erase(ir);
    }
  }
  pair<long long, long long> ret;
  int l = 1, r = MAX - 3, mid;
  while (l < r) {
    mid = (l + r + 1) >> 1;
    ret = check(mid);
    if (ret.first >= K)
      l = mid;
    else
      r = mid - 1;
  }
  ret = check(l);
  printf("%I64d\n", ret.second - (ret.first - K) * l);
}
pair<long long, long long> check(int tst) {
  long long cc = 0, sum = 0;
  long long ps1 = 0, ps2 = MAX;
  memset(vc, 0, sizeof(vc));
  vc[0] = MAX;
  int pi = 1, il = 0;
  for (int i = 1; i <= n; ++i) {
    for (; opt[pi] == i && pi <= kp; ++pi) {
      vc[op[pi].first] += op[pi].second;
      if (op[pi].first >= il)
        ps2 += op[pi].second;
      else
        ps1 += static_cast<long long>(op[pi].first) * op[pi].second;
    }
    while (il < i && ps2 - vc[il] >= tst) {
      ps1 += static_cast<long long>(il) * vc[il], ps2 -= vc[il];
      ++il;
    }
    cc += il, sum += ps1 + ps2 * il;
  }
  return make_pair(cc, sum);
}
