#include <bits/stdc++.h>
using namespace std;
bool sortbyfirstgreater(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
bool sortbysecondsmaller(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first == b.first) {
    return (a.second < b.second);
  }
  return (a.first > b.first);
}
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;
  }
  sort(a.begin(), a.end(), sortbyfirstgreater);
  sort(a.begin(), a.end(), sortbysecondsmaller);
  int ans = 0;
  k = k - 1;
  for (int i = 0; i < n; i++) {
    if (a[i].first == a[k].first && a[i].second == a[k].second) {
      ans++;
    }
  }
  cout << ans;
}
