#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 10;
const long long INF = 2e9;
long long n, k;
long long l[N], r[N];
long long delta[N];
vector<pair<long long, long long> > a[N];
struct segment {
  long long l, r, val;
};
bool operator<(segment a, segment b) { return a.l < b.l; }
multiset<segment> S;
template <typename T>
inline void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
inline void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
  x *= f;
}
inline long long cnt(long long mid) {
  memset(delta, 0, sizeof(delta));
  long long ans = 0, now = 0, l = 1;
  for (long long i = 1; i <= n; ++i) {
    unsigned j = 0;
    while (j < a[i].size() && a[i][j].first <= l) now += a[i][j++].second;
    while (l <= i && now >= mid) {
      now += delta[++l];
      while (j < a[i].size() && a[i][j].first <= l) now += a[i][j++].second;
    }
    ans += l - 1;
    while (j < a[i].size()) delta[a[i][j].first] += a[i][j].second, ++j;
    if (ans > INF) return INF;
  }
  return ans;
}
inline long long sum(long long mid) {
  memset(delta, 0, sizeof(delta));
  long long ans = 0, now = 0;
  long long l = 1;
  for (long long i = 1; i <= n; ++i) {
    unsigned j = 0;
    while (j < a[i].size() && a[i][j].first <= l) {
      ans += 1LL * (n - i + 1) * (l - a[i][j].first) * a[i][j].second;
      now += a[i][j++].second;
    }
    while (l <= i && now >= mid) {
      ans += 1LL * (n - i + 1) * now;
      now += delta[++l];
      while (j < a[i].size() && a[i][j].first <= l) now += a[i][j++].second;
    }
    while (j < a[i].size()) delta[a[i][j].first] += a[i][j].second, ++j;
  }
  return ans;
}
signed main() {
  read(n);
  read(k);
  for (long long i = 1; i <= n; ++i) {
    read(l[i]);
    read(r[i]);
    --r[i];
  }
  S.insert((segment){1, INF, 0});
  for (long long i = 1; i <= n; ++i) {
    multiset<segment>::iterator it = S.upper_bound((segment){l[i], 0, 0});
    long long ql = l[i], qr = r[i], vl = i, vr = i;
    if (--it != S.end()) {
      ql = (*it).l;
      vl = (*it).val;
    }
    while (it != S.end() && (*it).l <= r[i]) {
      if ((*it).r >= r[i]) {
        qr = (*it).r;
        vr = (*it).val;
      }
      multiset<segment>::iterator tmp = it;
      a[i].push_back(make_pair((*tmp).val + 1, (*tmp).r - (*tmp).l + 1));
      ++it;
      S.erase(tmp);
    }
    if (ql ^ l[i]) {
      S.insert((segment){ql, l[i] - 1, vl});
      a[i].push_back(make_pair(vl + 1, ql - l[i]));
    }
    if (qr ^ r[i]) {
      S.insert((segment){r[i] + 1, qr, vr});
      a[i].push_back(make_pair(vr + 1, r[i] - qr));
    }
    S.insert((segment){l[i], r[i], i});
    a[i].push_back(make_pair(i + 1, -(r[i] - l[i] + 1)));
    sort(a[i].begin(), a[i].end());
  }
  long long l = 1, r = (long long)2e9, res = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (cnt(mid) >= k) {
      res = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  long long ans = res * (k - cnt(res + 1));
  printf("%lld\n", ans + sum(res + 1));
  return 0;
}
