#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
template <typename T>
T abs(const T& a) {
  if (a >= 0) return a;
  return -a;
}
double dist(double ax, double ay, double bx, double by) {
  return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}
bool lessthan(double a, double b, double epsilon = EPS) {
  return (b - a) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first != b.first) return a.first > b.first;
  return a.second < b.second;
}
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end(), cmp);
  vector<int> pos(n);
  pair<int, int> ant = v[0];
  int qtd = 1;
  int st = 0;
  for (int i = 1; i < n; ++i) {
    if (ant == v[i]) {
      qtd++;
    } else {
      for (int j = st; j < i; ++j) {
        pos[j] = qtd;
      }
      st = i;
      qtd = 1;
      ant = v[i];
    }
  }
  for (int i = st; i < n; ++i) {
    pos[i] = qtd;
  }
  cout << pos[k - 1] << endl;
  return 0;
}
