#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return a.first > b.first || (a.first == b.first && a.second < b.second);
}
int main() {
  int k, n;
  cin >> k >> n;
  vector<pair<int, int>> vc;
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    vc.push_back({x, y});
  }
  sort(vc.begin(), vc.end(), sortinrev);
  int ansx = vc[n - 1].first, ansy = vc[n - 1].second, cnt = 0;
  for (int i = 0; i < vc.size(); i++) {
    if (vc[i].first == ansx && vc[i].second == ansy) {
      cnt++;
    }
  }
  cout << cnt;
  return 0;
}
