#include <bits/stdc++.h>
using namespace std;
struct custom_sort {
  inline bool operator()(const pair<long long, long long>& pair1,
                         const pair<long long, long long>& pair2) {
    return (pair1.first > pair2.first ||
            (pair1.first == pair2.first && pair1.second < pair2.second));
  }
};
void test_case() {
  long long n, k;
  cin >> n >> k;
  vector<pair<long long, long long> > p(n);
  for (int i = 0; i < n; i++) {
    long long pi, ti;
    cin >> pi >> ti;
    p[i] = {pi, ti};
  }
  sort(p.begin(), p.end(), custom_sort());
  cout << count(p.begin(), p.end(), p[k - 1]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  test_case();
}
