#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, k, num = 0;
  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 = -a[i].first;
  }
  (sort(a.begin(), a.end()));
  int fi = a[k - 1].first, sec = a[k - 1].second;
  for (int i = 0; i < n; i++) {
    if (fi == a[i].first && sec == a[i].second) {
      num++;
    }
  }
  cout << num;
}
