#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793;
const double tau = 6.283185307179586;
const double epsilon = 1e-6;
using namespace std;
int scores[50];
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int p, t;
    cin >> p >> t;
    scores[i] = 100 * p + 100 - t;
  }
  sort(scores, scores + n);
  int res = 0;
  for (int i = 0, s = scores[n - k]; i < n; i++)
    if (scores[i] == s) ++res;
  cout << res << '\n';
  return 0;
}
