#include <bits/stdc++.h>
using namespace std;
bool mycomp(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first == p2.first) {
    return p1.second < p2.second;
  }
  return p1.first > p2.first;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, k;
  int p, t;
  cin >> n >> k;
  vector<pair<int, int>> arr;
  for (int i = 0; i < n; i++) {
    cin >> p >> t;
    arr.push_back({p, t});
  }
  sort(arr.begin(), arr.end(), mycomp);
  int cnt = 1;
  vector<int> temp, cntarr;
  for (int i = 1; i < n; i++) {
    if (arr[i].first == arr[i - 1].first &&
        arr[i].second == arr[i - 1].second) {
      cnt += 1;
    } else {
      if (temp.size() != 0) {
        int prev = temp.back();
        temp.push_back(cnt + prev);
        cntarr.push_back(cnt);
      } else {
        temp.push_back(cnt);
        cntarr.push_back(cnt);
      }
      cnt = 1;
    }
  }
  if (arr.size() == 1) {
    temp.push_back(cnt);
    cntarr.push_back(cnt);
  } else if (temp.size() == 0) {
    temp.push_back(cnt);
    cntarr.push_back(cnt);
  } else {
    temp.push_back(temp.back() + cnt);
    cntarr.push_back(cnt);
  }
  int index = lower_bound(temp.begin(), temp.end(), k) - temp.begin();
  cout << cntarr[index] << " ";
  return 0;
}
