#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[1000], b[1000];
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    scanf("%d", &b[i]);
  }
  int temp, temp2;
  for (int j = 0; j < n - 1; j++) {
    for (int i = 0; i < n - j - 1; ++i) {
      if (a[i] < a[i + 1]) {
        temp = a[i];
        a[i] = a[i + 1];
        a[i + 1] = temp;
        temp2 = b[i];
        b[i] = b[i + 1];
        b[i + 1] = temp2;
      }
    }
  }
  for (int j = 0; j < n - 1; j++) {
    for (int i = 0; i < n - j - 1; ++i) {
      if (b[i] > b[i + 1] && a[i] == a[i + 1]) {
        temp = a[i];
        a[i] = a[i + 1];
        a[i + 1] = temp;
        temp2 = b[i];
        b[i] = b[i + 1];
        b[i + 1] = temp2;
      }
    }
  }
  int ex = k - 1;
  int g1 = a[ex];
  int g2 = b[ex];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == g1 && b[i] == g2) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
