#include <bits/stdc++.h>
using namespace std;
inline void open(const char *s) {}
inline long long rd() {
  static long long x, f;
  x = 0;
  f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return f > 0 ? x : -x;
}
const long long N = 300010, Inf = 2e9;
struct seg {
  long long l, r, id;
  seg(long long l = 0, long long r = 0, long long id = 0)
      : l(l), r(r), id(id) {}
  inline bool operator<(const seg &a) const {
    return a.r == r ? l < a.l : r < a.r;
  }
};
set<seg> st;
set<seg>::iterator it, it1, it2;
long long n, m;
long long a[N];
vector<pair<long long, long long> > vec[N];
inline set<seg>::iterator split(long long x) {
  it = st.lower_bound(seg(0, x, 0));
  if (it->l == x) return it;
  seg hh = *it;
  st.erase(it);
  st.insert(seg(hh.l, x - 1, hh.id));
  st.insert(seg(x, hh.r, hh.id));
  return st.lower_bound(seg(0, x, 0));
}
inline long long check(long long L) {
  long long ans = 0, s = 0, l = 1;
  memset(a, 0, sizeof a);
  for (long long i = 1; i <= n; i++) {
    for (auto hh : vec[i]) {
      a[hh.first] += hh.second;
      if (hh.first <= l) s += hh.second;
    }
    while (s >= L) {
      for (auto hh : vec[l]) s -= hh.second;
      s += a[++l];
    }
    ans += l - 1;
  }
  return ans;
}
inline long long solve(long long L) {
  long long ans = 0, s1 = 0, l = 1, s2 = 0;
  memset(a, 0, sizeof a);
  for (long long i = 1; i <= n; i++) {
    for (auto hh : vec[i]) {
      a[hh.first] += hh.second;
      if (hh.first <= l) s1 += hh.second, s2 += 1ll * hh.first * hh.second;
    }
    while (s1 >= L) {
      for (auto hh : vec[l])
        s1 -= hh.second, s2 -= 1ll * hh.first * hh.second,
            ans += 1ll * hh.second * (l - hh.first + 1) * (n - i + 1);
      ++l;
      s1 += a[l];
      s2 += 1ll * l * a[l];
    }
    ans += s1 * l - s2;
  }
  return ans;
}
int main() {
  open("hh");
  n = rd();
  m = rd();
  st.insert(seg(1, Inf, 0));
  for (long long i = 1; i <= n; i++) {
    long long x = rd(), y = rd();
    --y;
    it2 = split(y + 1);
    it1 = split(x);
    for (it = it1; it != it2; ++it)
      vec[i].push_back(
          pair<long long, long long>(it->id + 1, it->r - it->l + 1));
    st.erase(it1, it2);
    st.insert(seg(x, y, i));
  }
  long long l = 1, r = 1e9, ans = 0;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (check(mid) >= m)
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%lld\n", solve(ans) - 1ll * (check(ans) - m) * ans);
  return 0;
}
