#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first == p2.first) return p1.second < p2.second;
  return p1.first > p2.first;
}
int main() {
  int n, k;
  cin >> n >> k;
  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);
  int i = k, j = k;
  while (i >= 0 and (v[i].first == v[k].first) and (v[i].second == v[k].second))
    i--;
  while (j < n and (v[j].first == v[k].first) and
         (v[j].second == v[k].second)) {
    j++;
  }
  cout << j - i - 1 << endl;
  return 0;
}
