#include <bits/stdc++.h>
using namespace std;
int main() {
  int Data1, Data2;
  pair<int, int> Search[51];
  cin >> Data1 >> Data2;
  for (int i = 1; i <= Data1; i++)
    cin >> Search[i].first >> Search[i].second, Search[i].first *= -1;
  sort(Search + 1, Search + Data1 + 1);
  cout << count(Search + 1, Search + Data1 + 1, Search[Data2]);
  return 0;
}
