#include <bits/stdc++.h>
using namespace std;
struct z {
  int solv, tim;
};
vector<z> V;
bool cmp(z a, z b) {
  if (a.solv > b.solv) {
    return true;
  } else if (a.solv == b.solv) {
    return a.tim < b.tim;
  } else
    return false;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    z tp;
    tp.solv = a;
    tp.tim = b;
    V.push_back(tp);
  }
  sort(V.begin(), V.end(), cmp);
  m--;
  z tp;
  tp = V[m];
  int ans = 1;
  for (int i = 0; i < m; i++) {
    if (tp.solv == V[i].solv && tp.tim == V[i].tim) ans++;
  }
  for (int i = m + 1; i < n; i++) {
    if (tp.solv == V[i].solv && tp.tim == V[i].tim) ans++;
  }
  cout << ans << endl;
  return 0;
}
