#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k, i, tt = 1, a, b;
  cin >> n >> k;
  vector<pair<int, int> > p;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    p.push_back(make_pair(-a, b));
  }
  sort(p.begin(), p.end());
  for (i = k - 1; i < n - 1; i++) {
    if (p[i].first == p[i + 1].first && p[i].second == p[i + 1].second)
      tt += 1;
    else
      break;
  }
  for (i = k - 1; i > 0; i--) {
    if (p[i].first == p[i - 1].first && p[i].second == p[i - 1].second)
      tt += 1;
    else
      break;
  }
  cout << tt;
}
