#include <bits/stdc++.h>
using namespace std;
void readInputData();
void run();
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  readInputData();
  run();
  return 0;
}
class Team {
 public:
  int p;
  int t;
  int rank;
  Team() : p(0), t(0), rank(0) {}
  bool operator<(const Team& team) const {
    return (p > team.p) || (p == team.p && t < team.t);
  }
};
int n;
int k;
Team team[50];
void readInputData() {
  cin >> n >> k;
  k--;
  for (int i = 0; i < n; ++i) {
    cin >> team[i].p >> team[i].t;
  }
}
void run() {
  sort(team, team + n);
  team[0].rank = 1;
  for (int i = 1; i < n; ++i) {
    if (team[i - 1].p == team[i].p && team[i - 1].t == team[i].t) {
      team[i].rank = team[i - 1].rank;
    } else {
      team[i].rank = team[i - 1].rank + 1;
    }
  }
  int answer = 0;
  for (int i = 0; i < n; ++i) {
    answer += team[k].rank == team[i].rank;
  }
  cout << answer;
}
