#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, k;
  cin >> n >> k;
  int arr[n][2];
  for (int i = 0; i < n; i++) {
    cin >> arr[i][0] >> arr[i][1];
  }
  int sorted[n][2];
  for (int i = 0, k = 0; i < n; i++) {
    int mn = 1000000, smn = 1000000, in;
    for (int j = 0; j < n; j++) {
      if (arr[j][0] < mn) {
        mn = arr[j][0];
        smn = arr[j][1];
        in = j;
      } else if (arr[j][0] == mn && arr[j][0] != 1000) {
        if (arr[j][1] > smn) {
          mn = arr[j][0];
          smn = arr[j][1];
          in = j;
        }
      }
    }
    sorted[k][0] = arr[in][0];
    sorted[k][1] = arr[in][1];
    k++;
    arr[in][0] = 1000;
  }
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (sorted[i][0] == sorted[n - k][0] && sorted[i][1] == sorted[n - k][1]) {
      c++;
    }
  }
  cout << c << '\n';
  return 0;
}
