#include <bits/stdc++.h>
using namespace std;
int n, k, a, b;
vector<pair<int, int> > t;
bool comp(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;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  while (n--) {
    cin >> a >> b;
    t.push_back(make_pair(a, b));
  }
  sort(t.begin(), t.end(), comp);
  int wyn = 0;
  for (auto i : t) {
    if (i.first == t[k - 1].first && i.second == t[k - 1].second) wyn++;
  }
  cout << wyn;
  return 0;
}
