#include <bits/stdc++.h>
using namespace std;
int countbit(int n) { return (n == 0) ? 0 : (1 + countbit(n & (n - 1))); }
int lowbit(int n) { return (n ^ (n - 1)) & n; }
int n, k;
struct Item {
  int num, pen;
};
Item I[60];
bool cmp(const Item &a, const Item &b) {
  if (a.num == b.num) return a.pen < b.pen;
  return a.num > b.num;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d%d", &I[i].num, &I[i].pen);
  sort(I, I + n, cmp);
  int ans = 0;
  for (int i = 0; i < n; ++i)
    if (I[i].num == I[k - 1].num && I[i].pen == I[k - 1].pen) ans++;
  printf("%d\n", ans);
  return 0;
}
