#include <bits/stdc++.h>
long long n10[10] = {1,      10,      100,      1000,      10000,
                     100000, 1000000, 10000000, 100000000, 1000000000};
using namespace std;
struct abc {
  int x, y;
} a[55];
bool cmp(abc b, abc m) {
  if (b.x == m.x) return (b.y < m.y);
  return (b.x > m.x);
}
int n, k;
int res = 0;
int main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i += 1) cin >> a[i].x >> a[i].y;
  sort(a + 1, a + n + 1, cmp);
  for (long long i = 1; i <= n; i += 1)
    if (a[i].x == a[k].x && a[i].y == a[k].y) res++;
  cout << res;
  return 0;
}
