#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, j, rank, ans = 0;
  cin >> n >> k;
  int a[n];
  for (i = 0; i < n; i++) {
    j = 0;
    cin >> rank;
    j = 1000 * rank;
    cin >> rank;
    a[i] = j -= rank;
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (i = 0; i < n; i++)
    if (a[i] == a[k - 1]) ans++;
  cout << ans << endl;
  return 0;
}
