#include <bits/stdc++.h>
using namespace std;
struct a {
  int p, t;
} num[55];
int cmp(a x1, a x2) {
  if (x1.p != x2.p) {
    return x1.p > x2.p;
  } else {
    return x1.t < x2.t;
  }
}
int acount, n, k, p, x, y;
int main() {
  while (~scanf("%d %d", &n, &k)) {
    p = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &num[i].p, &num[i].t);
    }
    sort(num, num + n, cmp);
    for (int i = 0; i < n; i++) {
      if (i == k - 1) {
        x = num[i].p;
        y = num[i].t;
        break;
      }
    }
    for (int i = 0; i < n; i++) {
      if (x == num[i].p && y == num[i].t) {
        p++;
      }
    }
    printf("%d\n", p);
  }
}
