#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
long long sum(long long a, long long b)
{
return (a + b) * (b - a + 1) / 2;
}
int main(int argc, char* argv[])
{
int n, k;
scanf("%d%d", &n, &k);
vector<pair<int, int> > a;
for (int i = 0; i < n; i++)
{
int x, y;
scanf("%d%d", &x, &y);
a.push_back({x, 1});
a.push_back({y+1, -1});
}
sort(a.begin(), a.end());
long long res = 0;
int bal = 1;
for (int i = 1; i < a.size(); i++)
{
if (bal > 0)
{
int cnt = a[i].first - a[i-1].first;
cnt = min(cnt, k);
res += sum(a[i-1].first, a[i-1].first + cnt - 1);
k -= cnt;
}
bal += a[i].second;
}
if (k != 0) res = -1;
cout<<res<<endl;
}