#include <bits/stdc++.h>
struct gra {
  int num;
  int t;
};
struct gra a[55], temp;
int main() {
  int n, k, i, j, count;
  while (scanf("%d%d", &n, &k) != EOF) {
    for (i = 0; i < n; i++) scanf("%d%d", &a[i].num, &a[i].t);
    for (i = 1; i < n; i++)
      for (j = 0; j < n - i; j++) {
        if (a[j].num < a[j + 1].num) {
          temp = a[j];
          a[j] = a[j + 1];
          a[j + 1] = temp;
        } else if (a[j].num == a[j + 1].num)
          if (a[j].t > a[j + 1].t) {
            temp = a[j];
            a[j] = a[j + 1];
            a[j + 1] = temp;
          }
      }
    count = 1;
    for (i = k - 2;; i--) {
      if (a[i].num == a[k - 1].num && a[i].t == a[k - 1].t)
        count++;
      else
        break;
    }
    for (i = k;; i++) {
      if (a[i].num == a[k - 1].num && a[i].t == a[k - 1].t)
        count++;
      else
        break;
    }
    printf("%d\n", count);
  }
}
