#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  pair<int, int> p[n];
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    p[i] = {a, -b};
  }
  sort(p, p + n, greater<pair<int, int>>());
  for (int i = 0; i < n; i++) {
    if (p[i].first == p[k - 1].first && p[i].second == p[k - 1].second) ans++;
  }
  cout << ans << '\n';
  return 0;
}
