#include <bits/stdc++.h>
using namespace std;
int arr[51][51] = {0};
int main() {
  int n, r, a, b, ct = 0, flag = 0, p, i, j;
  scanf("%d%d", &n, &p);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    arr[a][b]++;
  }
  for (i = 50; i >= 0; i--) {
    for (j = 0; j < 51; j++) {
      ct += arr[i][j];
      if (ct >= p) {
        printf("%d", arr[i][j]);
        flag = 1;
        break;
      }
    }
    if (flag == 1) break;
  }
  return 0;
}
