#include <bits/stdc++.h>
using namespace std;
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }
};
int main() {
  int n, k, c = 0;
  cin >> n >> k;
  vector<pair<int, int> > v;
  vector<pair<int, int> > v1;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
  }
  Comp comp_functor;
  sort(v.begin(), v.end(), comp_functor);
  for (int i = n - 1; i >= 0; i--) {
    v1.push_back(v[i]);
  }
  for (int i = 0; i < n; i++) {
    if (v1[i].first == v1[i + 1].first && v1[i].second == v1[i + 1].second)
      c++;
    else if (i >= k - 1) {
      cout << c + 1;
      break;
    } else
      c = 0;
  }
  return 0;
}
