#include <bits/stdc++.h>
typedef struct {
  int p, t;
} gra;
int comp(const void* g1, const void* g2);
int main() {
  int i, j, n, k, r = 0;
  gra a[50];
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &a[i].p, &a[i].t);
  }
  qsort(a, n, sizeof(gra), comp);
  for (i = k - 2; i >= 0 && a[i].p == a[k - 1].p; i--) {
    if (a[i].t == a[k - 1].t) r++;
  }
  for (i = k; i < n && a[i].p == a[k - 1].p; i++) {
    if (a[i].t == a[k - 1].t) r++;
  }
  printf("%d", r + 1);
  return 0;
}
int comp(const void* g1, const void* g2) {
  if (((gra*)g2)->p - ((gra*)g1)->p > 0) {
    return 1;
  }
  if (((gra*)g2)->p - ((gra*)g1)->p < 0) {
    return -1;
  }
  return ((gra*)g1)->t - ((gra*)g2)->t;
}
