#include <bits/stdc++.h>
using namespace std;
using Team = pair<int, int>;
int solve(vector<Team> &teams, int k) {
  auto cmp = [](const Team &a, const Team &b) {
    return a.first > b.first || (a.first == b.first && a.second < b.second);
  };
  sort(teams.begin(), teams.end(), cmp);
  const Team &team = teams[k - 1];
  return upper_bound(teams.begin(), teams.end(), team, cmp) -
         lower_bound(teams.begin(), teams.end(), team, cmp);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<Team> teams;
  teams.reserve(n);
  for (int i = 0; i < n; ++i) {
    int p, t;
    cin >> p >> t;
    teams.push_back(make_pair(p, t));
  }
  cout << solve(teams, k) << endl;
  return 0;
}
