#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long Inf = 1e18;
const int N = 3e5 + 10;
const int mod = 0;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
};
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
};
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }
void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }
int n, m, f[N];
set<pair<int, int> > s;
vector<pair<int, int> > v[N];
int main() {
  cin >> n >> m;
  s.insert(make_pair(0, 0));
  s.insert(make_pair(inf, 0));
  for (int i = 1, l, r, x; i <= n; i++) {
    l = gi(), r = gi();
    auto it = s.upper_bound(make_pair(l, i)), it2 = it;
    --it;
    v[i].push_back(make_pair(x = it->second, it->first - it2->first));
    if (it->first < l)
      v[i].push_back(make_pair(it->second, l - it->first));
    else
      s.erase(it);
    while (it2->first < r)
      it = it2, it2++,
      v[i].push_back(make_pair(x = it->second, it->first - it2->first)),
      s.erase(it);
    if (it2->first > r)
      s.insert(make_pair(r, x)), v[i].push_back(make_pair(x, it2->first - r));
    v[i].push_back(make_pair(i, r - l));
    s.insert(make_pair(l, i));
  }
  int l = 1, r = 1e9;
  long long r1 = 0, r2 = 0, ret = 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    memset(f, 0, sizeof(f));
    long long s1 = 0, s2 = 0, t1 = 0, t2 = 0;
    for (int i = 1, j = 1; i <= n; i++) {
      for (auto x : v[i]) {
        if (x.first < j)
          t1 += 1ll * x.first * x.second;
        else
          t1 += 1ll * (j - 1) * x.second, t2 += x.second,
              f[x.first] += x.second;
      }
      while (j <= i && t2 >= mid) t1 += t2, t2 -= f[j], j++;
      s1 += t1;
      s2 += j - 1;
    }
    if (s2 >= m)
      r1 = s1, r2 = s2, ret = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%lld\n", r1 - ret * (r2 - m));
  return 0;
}
