#include <bits/stdc++.h>
const int SIZE = 50;
using namespace std;
struct final_result {
  int solved_problems, penalty_time;
  final_result() {}
  friend final_result operator>>(istream& input, final_result& tmp) {
    input >> tmp.solved_problems >> tmp.penalty_time;
    return tmp;
  }
  friend bool operator==(const final_result& teamA, final_result& teamB) {
    return teamA.solved_problems == teamB.solved_problems &&
           teamA.penalty_time == teamB.penalty_time;
  }
};
struct ranking {
  inline bool operator()(const final_result& teamA, const final_result& teamB) {
    if (teamA.solved_problems != teamB.solved_problems)
      return teamA.solved_problems > teamB.solved_problems;
    else
      return teamA.penalty_time < teamB.penalty_time;
  }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  final_result teams[50];
  for (int i = 0; i < n; i++) cin >> teams[i];
  sort(teams, teams + n, ranking());
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (teams[i] == teams[k - 1]) count++;
  }
  cout << count;
  return 0;
}
