#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> p;
multiset<pair<long long, long long>> ms;
multiset<pair<long long, long long>>::iterator it, jt;
long long n, i, k, a, b, c;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    ms.insert(make_pair((-1) * a, b));
  }
  it = ms.begin();
  k = k - 1;
  while (k--) it++;
  for (jt = ms.begin(); jt != ms.end(); jt++) {
    if ((*jt).first == (*it).first && (*jt).second == (*it).second) c++;
  }
  cout << c;
  return 0;
}
