#include <bits/stdc++.h>
using namespace std;
int Abs(int x) {
  if (x < 0) return -x;
  return x;
}
class p {
 public:
  int x, y;
  bool operator<(const p& a) const {
    if (a.x != x) return a.x < x;
    return a.y > y;
  }
};
p A[100];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) cin >> A[i].x >> A[i].y;
  sort(A, A + n);
  --k;
  int a = A[k].x, b = A[k].y;
  int cnt = 0;
  for (int i = 0; i < n; ++i)
    if (A[i].x == a && A[i].y == b) ++cnt;
  cout << cnt;
}
