#include <bits/stdc++.h>
int main(int argc, char** argv) {
  int n, k, i, j, x;
  scanf("%d%d", &n, &k);
  int a[n][2], r[n];
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a[i][0], &a[i][1]);
    r[i] = 0;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n - i - 1; j++) {
      if (a[j][0] < a[j + 1][0] ||
          (a[j][0] == a[j + 1][0] && a[j][1] > a[j + 1][1])) {
        x = a[j][0];
        a[j][0] = a[j + 1][0];
        a[j + 1][0] = x;
        x = a[j][1];
        a[j][1] = a[j + 1][1];
        a[j + 1][1] = x;
      }
    }
  }
  r[0] = 1;
  j = 0;
  for (i = 1; i < n; i++) {
    j = i;
    r[i]++;
    if (a[j][0] == a[j - 1][0] && a[j][1] == a[j - 1][1]) {
      while (a[j][0] == a[j - 1][0] && a[j][1] == a[j - 1][1]) {
        r[i]++;
        j++;
      }
      for (x = i - 1; x < j; x++) {
        r[x] = r[i];
      }
      i = j - 1;
    }
  }
  printf("%d", r[k - 1]);
  return (EXIT_SUCCESS);
}
