#include <bits/stdc++.h>
using namespace std;
bool funct(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first) {
    if (a.second > b.second)
      return false;
    else
      return true;
  } else
    return false;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> arr(n);
  for (int i = 0; i < n; i++) {
    pair<int, int> p;
    int a, b;
    cin >> a >> b;
    p = make_pair(a, b);
    arr[i] = p;
  }
  sort(arr.begin(), arr.end(), funct);
  pair<int, int> s = arr[k - 1];
  int out = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == s) out++;
  }
  cout << out;
  return 0;
}
