#include <bits/stdc++.h>
using namespace std;
struct team {
  int p;
  int t;
};
bool fn_p(struct team x, struct team y) { return x.p > y.p; }
bool fn_t(struct team x, struct team y) { return x.t < y.t; }
int main() {
  int n, k;
  cin >> n >> k;
  team a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i].p >> a[i].t;
  }
  sort(a, a + n, fn_p);
  for (int i = 0; i < n - 1; i++) {
    int j = i;
    while (a[i].p == a[i + 1].p) {
      i++;
    }
    sort(a + j, a + i + 1, fn_t);
  }
  int j = k - 1;
  int cnt = 1;
  while (j < n - 1) {
    if (a[j].p == a[j + 1].p && a[j].t == a[j + 1].t) {
      cnt++;
      j++;
    } else {
      break;
    }
  }
  j = k - 1;
  while (j > 0) {
    if (a[j].p == a[j - 1].p && a[j].t == a[j - 1].t) {
      cnt++;
      j--;
    } else {
      break;
    }
  }
  cout << cnt;
  return 0;
}
