#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<pair<int, int> > a;
  int p, t;
  for (int i = 0; i < n; ++i) {
    cin >> p >> t;
    a.push_back({-p, t});
  }
  sort(a.begin(), a.end());
  cout << upper_bound(a.begin(), a.end(), a[k - 1]) -
              lower_bound(a.begin(), a.end(), a[k - 1]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) solve();
  return 0;
}
