#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > v;
  while (n--) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(-x, y));
  }
  sort(v.begin(), v.end());
  int ind = k - 1;
  int res = 1;
  while (ind - 1 >= 0 && v[ind] == v[ind - 1]) {
    ind--;
    res++;
  }
  ind = k - 1;
  while (ind + 1 < v.size() && v[ind] == v[ind + 1]) {
    ind++;
    res++;
  }
  cout << res << endl;
  return 0;
}
