#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > vec;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    vec.push_back(make_pair(100 - a, b));
  }
  sort(vec.begin(), vec.end());
  pair<int, int> tmp;
  tmp = vec[k - 1];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (tmp == vec[i]) {
      cnt++;
    }
  }
  cout << cnt;
  cin >> cnt;
  return 0;
};
