#include <bits/stdc++.h>
using namespace std;
pair<int, int> p[50];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
    p[i].first *= -1;
  }
  sort(p, p + n);
  cout << count(p, p + n, p[k - 1]);
  return 0;
}
