#include <bits/stdc++.h>
using namespace std;
struct data {
  int p, t;
} a[60];
bool cmp(data x, data y) { return x.p == y.p ? x.t < y.t : x.p > y.p; }
int main() {
  int n, k, min, max, mid, l, r, i;
  scanf("%d %d", &n, &k);
  for (i = 0; i ^ n; i++) scanf("%d %d", &a[i].p, &a[i].t);
  k--;
  sort(a, a + n, cmp);
  min = 0;
  max = k;
  while (min < max) {
    mid = (min + max) / 2;
    if (a[mid].p > a[k].p || (a[mid].p == a[k].p && a[mid].t < a[k].t))
      min = mid + 1;
    else
      max = mid;
  }
  l = min;
  min = k;
  max = n - 1;
  while (min < max) {
    mid = (min + max) / 2;
    if (mid == min) mid++;
    if (a[mid].p < a[k].p || (a[mid].p == a[k].p && a[mid].t > a[k].t))
      max = mid - 1;
    else
      min = mid;
  }
  r = max;
  printf("%d\n", r - l + 1);
  return 0;
}
