#include <bits/stdc++.h>
using namespace std;
struct s {
  long long x;
  long long y;
};
vector<s> v;
bool cmp(s a, s b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x > b.x;
}
int main() {
  long long a, b, c, d, e, i, j, k, xx, yy;
  s aa, bb;
  scanf("%lld %lld", &a, &b);
  for (i = 0; i < a; i++) {
    scanf("%lld %lld", &aa.x, &aa.y);
    v.push_back(aa);
  }
  sort(v.begin(), v.end(), cmp);
  xx = v[b - 1].x;
  yy = v[b - 1].y;
  long long count = 0;
  for (i = 0; i < a; i++) {
    if (xx == v[i].x && yy == v[i].y) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
