#include <bits/stdc++.h>
using namespace std;
void def1() {}
void def2() {}
bool comp(pair<int, int> a, pair<int, int> b) {
  if (b.first > a.first)
    return 0;
  else if (a.first > b.first)
    return 1;
  else
    return (b.second <= a.second ? 0 : 1);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end(), comp);
  map<pair<int, int>, int> m;
  for (int i = 0; i < n; ++i) m[v[i]]++;
  for (int i = 0, j = 1; i < n; ++i) {
    if (i + 1 == k) {
      cout << m[v[i]];
      break;
    }
  }
}
