#include <bits/stdc++.h>
using namespace std;
struct r {
  int p, t;
} a;
vector<r> v;
bool sss(const r& i, const r& j) {
  if (i.p > j.p)
    return true;
  else if (i.p == j.p)
    return i.t < j.t;
  else
    return false;
}
int main() {
  int n, k;
  cin >> n >> k;
  map<pair<int, int>, int> mp;
  for (int cs = 1; cs <= n; cs++) {
    cin >> a.p >> a.t;
    mp[make_pair(a.p, a.t)]++;
    v.push_back(a);
  }
  sort(v.begin(), v.end(), sss);
  cout << mp[{v[k - 1].p, v[k - 1].t}] << endl;
  return 0;
}
