#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n, k;
  cin >> n >> k;
  map<int, vector<int> > teams;
  for (int i = 0; i < n; i++) {
    int p, t;
    cin >> p >> t;
    teams[p].push_back(t);
  }
  int ans = -1;
  vector<int> ansv;
  for (auto it = teams.rbegin(); it != teams.rend(); ++it) {
    vector<int> v = it->second;
    int l = v.size();
    if (l >= k) {
      ans = it->first;
      ansv = it->second;
      break;
    } else {
      k -= l;
    }
  }
  sort(ansv.begin(), ansv.end());
  int count = ansv[k - 1], freq = 0;
  for (auto i : ansv) {
    if (count == i) freq++;
  }
  cout << freq;
}
