#include <bits/stdc++.h>
using namespace std;
struct Comp {
  bool operator()(const pair<int, int>& a, const pair<int, int>& b) {
    if (a.first != b.first) {
      return a.first > b.first;
    }
    return a.second < b.second;
  }
};
int main() {
  int n, k, teams = 1;
  Comp comp_func;
  cin >> n >> k;
  vector<pair<int, int>> rank(n);
  for (int i = 0; i < n; ++i) cin >> rank[i].first >> rank[i].second;
  sort(rank.begin(), rank.end(), comp_func);
  for (int i = (k - 2); i >= 0 && rank[k - 1].first == rank[i].first &&
                        rank[k - 1].second == rank[i].second;
       --i)
    ++teams;
  for (int i = k; i < n && rank[k - 1].first == rank[i].first &&
                  rank[k - 1].second == rank[i].second;
       ++i)
    ++teams;
  cout << teams << endl;
  return 0;
}
