#include <bits/stdc++.h>
using namespace std;
;
vector<pair<int, int>> vec;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k, a, b, c;
  c = 1;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    vec.push_back(make_pair(a * -1, b));
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    if (i == k - 1) {
      while (vec[i] == vec[i + 1]) {
        i++;
        c++;
      }
      cout << c << '\n';
      break;
    }
    if (vec[i] == vec[i + 1])
      c++;
    else
      c = 1;
  }
  cout.flush();
}
