#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
bool prm[(long long)2e7 + 5];
vector<int> prm_no;
void make_prm() {
  prm[0] = prm[1] = true;
  for (int first = 2; first <= (long long)2e7 + 5; first++) {
    if (!prm[first]) {
      prm_no.push_back(first);
      for (int second = 2 * first; second <= (long long)2e7 + 5;
           second += first)
        prm[second] = true;
    }
  }
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
int main() {
  int n, k;
  cin >> n >> k;
  k--;
  vector<pair<int, int> > ans;
  map<pair<int, int>, int> oc;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    ans.push_back({x, y});
    oc[{x, y}]++;
  }
  sort((ans).begin(), (ans).end(), cmp);
  cout << oc[ans[k]];
}
