#include <bits/stdc++.h>
using namespace std;
struct my {
  int x, y;
};
bool operator<(my ob1, my ob2) {
  if (ob1.x != ob2.x)
    return ob1.x > ob2.x;
  else
    return ob1.y < ob2.y;
}
int main() {
  int n, k, i;
  cin >> n >> k;
  my ob[n];
  for (i = 0; i < n; i++) {
    cin >> ob[i].x >> ob[i].y;
  }
  sort(ob, ob + n);
  int winning_score, winning_penalty, cnt = 0;
  winning_score = ob[k - 1].x;
  winning_penalty = ob[k - 1].y;
  for (i = 0; i < n; i++) {
    if (ob[i].x == winning_score && ob[i].y == winning_penalty) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
