#include <bits/stdc++.h>
using namespace std;
int a[60], b[60], h, i, j, k, l, m, n, ans;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++)
      if ((a[i] < a[j]) || ((a[i] == a[j]) && (b[i] > b[j]))) {
        h = a[i];
        a[i] = a[j];
        a[j] = h;
        h = b[i];
        b[i] = b[j];
        b[j] = h;
      }
  ans = 0;
  a[n + 1] = -1;
  for (i = m - 1; (a[i] == a[m]) && (b[i] == b[m]); i--)
    ;
  for (j = m + 1; (a[j] == a[m]) && (b[j] == b[m]); j++)
    ;
  ans = j - i - 1;
  printf("%d\n", ans);
  return 0;
}
