#include <bits/stdc++.h>
using namespace std;
const int MAXN = 110;
const long long int INF = 1e12;
int pontos[MAXN], custo[MAXN];
int n, k;
long long dp[MAXN][MAXN][MAXN];
long long solve(int i, int rank, int pt, int val) {
  if (i == n) {
    if (rank < k && pt >= val)
      return 0;
    else
      return INF;
  }
  if (dp[i][rank][pt] == -1) {
    long long ans = INF;
    if (pontos[i] + 1 >= val)
      ans = min(ans, solve(i + 1, rank + 1, pt, val));
    else
      ans = min(ans, solve(i + 1, rank, pt, val));
    if (pontos[i] > val)
      ans = min(ans, solve(i + 1, rank + 1, pt + 1, val) + custo[i]);
    else
      ans = min(ans, solve(i + 1, rank, pt + 1, val) + custo[i]);
    dp[i][rank][pt] = ans;
  }
  return dp[i][rank][pt];
}
int main(void) {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", pontos + i, custo + i);
  }
  long long best = INF;
  for (int i = 0; i <= n; i++) {
    memset(dp, -1, sizeof dp);
    best = min(best, solve(0, 0, 0, i));
  }
  if (best == INF)
    cout << "-1\n";
  else
    cout << best << endl;
}
