#include <bits/stdc++.h>
using namespace std;
bool isprime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int n, k;
  cin >> n >> k;
  int p, t;
  map<int, vector<int>> m;
  for (int i = 0; i < n; i++) {
    cin >> p >> t;
    m[p].push_back(t);
  }
  int id;
  int sum = 0;
  vector<vector<int>> vv;
  for (auto i : m) {
    vv.push_back(i.second);
  }
  reverse(vv.begin(), vv.end());
  for (int i = 0; i < vv.size(); i++) {
    if (vv[i].size() + sum < k) {
      sum += vv[i].size();
    } else {
      id = i;
      break;
    }
  }
  sort(vv[id].begin(), vv[id].end());
  int q = (k - sum) - 1;
  int z = vv[id][q];
  cout << count(vv[id].begin(), vv[id].end(), z);
}
