#include <bits/stdc++.h>
using namespace std;
struct team {
  int prob;
  int time;
};
bool comp(team a, team b) {
  return (a.prob > b.prob) || ((a.prob == b.prob) && (a.time < b.time));
}
int main(int argc, char const *argv[]) {
  int n, k;
  cin >> n >> k;
  team t[n];
  for (int i = 0; i < n; ++i) {
    cin >> t[i].prob >> t[i].time;
  }
  sort(t, t + n, comp);
  team tk;
  tk = t[k - 1];
  int count = 1;
  int i = k - 2;
  int j = k;
  while ((tk.time == t[i].time) && (tk.prob == t[i].prob) && (i >= 0)) {
    count++;
    i--;
  }
  while ((tk.time == t[j].time) && (tk.prob == t[j].prob) && (j < n)) {
    count++;
    j++;
  }
  cout << count << endl;
  return 0;
}
