#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > score;
map<pair<int, int>, int> freq;
bool compare(const pair<int, int> a, const pair<int, int> b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
void solve() {
  int n, k;
  cin >> n >> k;
  for (int(i) = (0); (i) < (n); ++(i)) {
    int x, y;
    cin >> x >> y;
    pair<int, int> curr = make_pair(x, y);
    score.push_back(curr);
    ++freq[curr];
  }
  sort((score).begin(), (score).end(), compare);
  cout << freq[score[k - 1]];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
    cout << '\n';
  }
  return 0;
}
