#include <bits/stdc++.h>
using namespace std;
bool ch(pair<int, int> q, pair<int, int> w) {
  if (q.first > w.first || (q.first == w.first && q.second < w.second))
    return true;
  else
    return false;
}
int main() {
  int n, k, t1, t2;
  vector<pair<int, int> > a;
  int pg, pl, br1, br2, s = 0, k1, k2;
  vector<int> u;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &t1, &t2);
    a.push_back(make_pair(t1, t2));
  }
  sort(a.begin(), a.end(), ch);
  k--;
  br1 = a[k].first;
  br2 = a[k].second;
  while (a[k].first == br1 && a[k].second == br2) k--;
  k++;
  while (a[k].first == br1 && a[k].second == br2) {
    k++;
    s++;
  }
  printf("%d", s);
  return 0;
}
