#include <bits/stdc++.h>
using namespace std;
bool fn(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) {
    return true;
  } else if (a.first == b.first) {
    return a.second < b.second;
  }
  return false;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> vc(n);
  int ta, tb;
  for (int i = 0; i < n; i++) {
    cin >> ta >> tb;
    vc[i] = make_pair(ta, tb);
  }
  sort(vc.begin(), vc.end(), fn);
  auto t = vc[k - 1];
  auto l = lower_bound(vc.begin(), vc.end(), t, fn);
  auto h = upper_bound(vc.begin(), vc.end(), t, fn);
  cerr << "DEBUG: " << l - vc.begin() << ' ' << h - vc.begin() << endl;
  ;
  cout << h - vc.begin() - (l - vc.begin()) << endl;
}
