#include <bits/stdc++.h>
struct team {
  int p, t;
};
int cmp(const void *a1, const void *a2) {
  const struct team *a = (const struct team *)a1;
  const struct team *b = (const struct team *)a2;
  if (a->p > b->p) return -1;
  if (a->p < b->p) return 1;
  if (a->t < b->t) return -1;
  if (a->t > b->t) return 1;
  return 0;
}
int main(void) {
  int k, n, i, j, m = 0;
  struct team *list;
  scanf("%d %d", &n, &k);
  list = (struct team *)calloc(n, sizeof(*list));
  for (i = 0; i < n; i++) {
    scanf("%d %d", &(list[i].p), &(list[i].t));
  }
  qsort(list, n, sizeof(*list), cmp);
  j = --k;
  while (j >= 0 && j < n && cmp(&list[j], &list[k]) == 0) {
    j--;
    m++;
  }
  j = k;
  while (j >= 0 && j < n && cmp(&list[j], &list[k]) == 0) {
    j++;
    m++;
  }
  m--;
  printf("%d", m);
  return EXIT_SUCCESS;
}
