#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> y1, pair<int, int> y2) {
  if (y1.first == y2.first)
    return y1.second < y2.second;
  else
    return y1.first > y2.first;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  int n, index;
  cin >> n >> index;
  vector<pair<int, int> > Rank;
  vector<pair<int, int> >::iterator it1, it2;
  int t1, t2;
  for (int i = 0; i < n; i++) {
    cin >> t1 >> t2;
    Rank.push_back(make_pair(t1, t2));
  }
  sort(Rank.begin(), Rank.end(), comp);
  pair<int, int> val = make_pair(Rank[index - 1].first, Rank[index - 1].second);
  it1 = upper_bound(Rank.begin(), Rank.end(), val, comp);
  it2 = lower_bound(Rank.begin(), Rank.end(), val, comp);
  cout << it1 - it2;
  return 0;
}
