#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i].first >> a[i].second, a[i].first *= -1;
  sort(a.begin(), a.end());
  cout << count(a.begin(), a.end(), a[k - 1]) << endl;
  return 0;
}
