#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > V(n);
  for (register int i = (0); i < (int)(n); ++i)
    cin >> V[i].first >> V[i].second, V[i].second *= -1;
  sort((V).begin(), (V).end());
  reverse((V).begin(), (V).end());
  int x = k - 1, y = k - 1;
  while (x > 0 && V[x - 1] == V[x]) x--;
  while (y < ((int)(V).size()) - 1 && V[y] == V[y + 1]) y++;
  cout << y - x + 1 << "\n";
  return 0;
}
