#include <bits/stdc++.h>
using std::pair;
using std::set;
using std::vector;
int n, k, a[300005], b[300005], mx, tag[300005];
set<pair<pair<int, int>, int> > st;
vector<pair<pair<int, int>, int> > del, ins;
vector<pair<int, int> > op[300005];
inline void insert(int l, int r, int col) {
  auto it = st.lower_bound(std::make_pair(std::make_pair(l, r), 0));
  int tot = r - l;
  if (it != st.begin() && prev(it)->first.second > l) {
    auto pr = prev(it);
    if (pr->first.second >= r) {
      auto t = *pr;
      op[col].push_back(std::make_pair(t.second + 1, tot));
      st.insert(std::make_pair(std::make_pair(l, r), col));
      if (t.first.first < l)
        st.insert(std::make_pair(std::make_pair(t.first.first, l), t.second));
      if (t.first.second > r)
        st.insert(std::make_pair(std::make_pair(r, t.first.second), t.second));
      st.erase(t);
      return;
    }
    del.push_back(*pr);
    if (pr->first.first < l)
      ins.push_back(
          std::make_pair(std::make_pair(pr->first.first, l), pr->second));
    op[col].push_back(std::make_pair(pr->second + 1, pr->first.second - l));
    tot -= pr->first.second - l;
  }
  for (; it != st.end() && it->first.first <= r; ++it) {
    del.push_back(*it);
    if (it->first.second <= r) {
      op[col].push_back(
          std::make_pair(it->second + 1, it->first.second - it->first.first));
      tot -= it->first.second - it->first.first;
    } else {
      op[col].push_back(std::make_pair(it->second + 1, r - it->first.first));
      tot -= r - it->first.first;
      ins.push_back(
          std::make_pair(std::make_pair(r, it->first.second), it->second));
    }
  }
  op[col].push_back(std::make_pair(1, tot));
  for (auto t : del) st.erase(t);
  for (auto t : ins) st.insert(t);
  del.clear();
  ins.clear();
  st.insert(std::make_pair(std::make_pair(l, r), col));
}
long long calc(int len) {
  long long ret = 0;
  std::fill(tag, tag + n + 1, 0);
  for (int l = 1, r = 1, cur = 0; r <= n; ++r) {
    for (auto t : op[r]) {
      if (t.first <= l)
        cur += t.second;
      else
        tag[t.first] += t.second;
      tag[r + 1] -= t.second;
    }
    while (l < r && cur + tag[l + 1] >= len) ++l, cur += tag[l];
    if (cur >= len) ret += l;
  }
  return ret;
}
long long sum[300005], sum1[300005];
long long _ask(int p) {
  long long ret = 0;
  while (p) ret += sum[p], p -= p & (-p);
  return ret;
}
long long _ask1(int p) {
  long long ret = 0;
  while (p) ret += sum1[p], p -= p & (-p);
  return ret;
}
inline void _add(int p, long long v) {
  while (p <= n) sum[p] += v, p += p & (-p);
}
inline void _add1(int p, long long v) {
  while (p <= n) sum1[p] += v, p += p & (-p);
}
inline long long askpr(int r) { return (r + 1) * _ask(r) - _ask1(r); }
inline void addsuf(int p, int v) { _add(p, v), _add1(p, 1ll * p * v); }
inline long long ask(int l, int r) { return askpr(r) - askpr(l - 1); }
inline void add(int l, int r, int v) { addsuf(l, v), addsuf(r + 1, -v); }
long long calcans(int len) {
  long long ret = 0;
  std::fill(tag, tag + n + 1, 0);
  for (int l = 1, r = 1, cur = 0; r <= n; ++r) {
    for (auto t : op[r]) {
      if (t.first <= l)
        cur += t.second;
      else
        tag[t.first] += t.second;
      tag[r + 1] -= t.second;
      add(t.first, r, t.second);
    }
    while (l < r && cur + tag[l + 1] >= len) ++l, cur += tag[l];
    if (cur >= len) ret += ask(1, l);
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d", a + i, b + i), mx = std::max(b[i], mx);
  for (int i = 1; i <= n; ++i) insert(a[i], b[i], i);
  int l = 1, r = mx;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (calc(mid) >= k)
      l = mid;
    else
      r = mid - 1;
  }
  long long ans = 0;
  ans = calcans(l + 1) + 1ll * l * (k - calc(l + 1));
  printf("%lld\n", ans);
  return 0;
}
