#include <bits/stdc++.h>
using namespace std;
bool mycomp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first && a.second < b.second)
    return true;
  else
    return false;
}
int main() {
  int n, k, c = 0;
  cin >> n >> k;
  pair<int, int> a[n];
  for (int i = 0; i < n; ++i) cin >> a[i].first >> a[i].second;
  sort(a, a + n, mycomp);
  for (int i = 0; i < n; ++i)
    if (a[i].first == a[k - 1].first && a[i].second == a[k - 1].second) c++;
  cout << c << endl;
  return 0;
}
