#include <bits/stdc++.h>
using namespace std;
struct node {
  int problems;
  int penalty;
  int rank;
};
vector<node> arr;
bool comp(const struct node &t1, const struct node &t2) {
  if (t1.problems == t2.problems)
    return t1.penalty < t2.penalty;
  else
    return t1.problems > t2.problems;
}
int main() {
  int n, k;
  cin >> n >> k;
  node temp;
  int i;
  for (i = 0; i < n; i++) {
    cin >> temp.problems >> temp.penalty;
    arr.push_back(temp);
  }
  sort(arr.begin(), arr.end(), comp);
  vector<node>::iterator it;
  map<int, int> rank;
  temp = arr[0];
  int r = 1;
  int count1 = 0;
  for (i = 0; i < n; i++) {
    if (arr[i].problems == temp.problems && arr[i].penalty == temp.penalty) {
      count1++;
    } else {
      rank[r] = count1;
      count1 = 1;
      temp = arr[i];
      r++;
    }
    arr[i].rank = r;
  }
  rank[r] = count1;
  cout << rank[arr[k - 1].rank] << "\n";
  return 0;
}
