#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const long long MAXN = 600010;
const long long INF = 2147483600;
long long N, K;
struct data {
  long long l, r, id;
  bool operator<(const data &a) const {
    if (a.l != l) return l < a.l;
    return r < a.r;
  }
} q[MAXN + 1];
vector<pair<long long, long long> > vec[MAXN + 1];
set<data>::iterator Ers[MAXN + 1];
set<data> S;
long long sum[MAXN + 1], kans, pans;
inline data mdata(long long l, long long r, long long id) {
  data n;
  n.l = l;
  n.r = r;
  n.id = id;
  return n;
}
inline void check(long long x) {
  long long nw = 1, sm = 0;
  kans = 0;
  pans = 0;
  long long sumv = 0;
  for (long long i = 1; i <= N; i++) sum[i] = 0;
  for (long long i = 1; i <= N; i++) {
    long long sumt = 0;
    for (long long j = 0, sz = vec[i].size(); j < sz; j++) {
      pair<long long, long long> k = vec[i][j];
      sum[k.first] += k.second;
      sumt += k.second;
      if (k.first < nw) sm += k.second, sumv += k.second * (nw - k.first);
    }
    sum[i + 1] -= sumt;
    pans += sumv;
    while (nw <= i && sum[nw] + sm >= x)
      sm += sum[nw], pans += sm, sumv += sm, ++nw;
    kans += nw - 1;
  }
}
long long top;
int main() {
  N = read();
  K = read();
  for (long long i = 1; i <= N; i++) {
    q[i].l = read(), q[i].r = read() - 1;
    q[i].id = i;
  }
  for (long long i = 1; i <= N; i++) {
    set<data>::iterator it = S.upper_bound(q[i]);
    data l;
    top = 0;
    if (S.begin() != it) --it;
    if (it == S.end())
      l.l = INF;
    else
      l = (*it);
    while (it != S.end()) {
      if ((*it).r < q[i].l) {
        ++it;
        continue;
      }
      if ((*it).l > q[i].r) break;
      Ers[++top] = it;
      if ((*it).r >= q[i].r) break;
      ++it;
    }
    data r;
    r.r = -1;
    if (it != S.end()) r = (*it);
    long long last = q[i].l - 1;
    for (long long j = 1; j <= top; j++) {
      data x = (*Ers[j]);
      long long lt = max(x.l, q[i].l), rt = min(x.r, q[i].r);
      if (lt > rt) continue;
      if (last + 1 != lt) vec[i].push_back(make_pair(1, lt - last - 1));
      vec[i].push_back(make_pair(x.id + 1, rt - lt + 1));
      last = rt;
    }
    if (last != q[i].r) vec[i].push_back(make_pair(1, q[i].r - last));
    for (long long j = 1; j <= top; j++) S.erase(Ers[j]);
    if (l.l < q[i].l && l.r >= q[i].l) S.insert(mdata(l.l, q[i].l - 1, l.id));
    if (r.r > q[i].r && r.l <= q[i].r) S.insert(mdata(q[i].r + 1, r.r, r.id));
    S.insert(q[i]);
  }
  long long l = 0, r = 1000000000;
  long long ans = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    kans = 0;
    check(mid);
    if (kans < K)
      ans = pans + (mid - 1) * (K - kans), r = mid - 1;
    else
      l = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
