#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) {
  return (a.first > b.first || ((a.first == b.first) && (a.second < b.second)));
}
int main() {
  vector<pair<int, int> > v;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end(), comp);
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (v[i].first == v[k - 1].first && v[i].second == v[k - 1].second) c++;
  }
  cout << c << endl;
}
