#include <bits/stdc++.h>
using namespace std;
struct info {
  int tim, sol;
} in[60];
bool cmp(info a, info b) {
  if (a.sol == b.sol) return (a.tim < b.tim);
  return a.sol > b.sol;
}
int main() {
  int n, p, t, i, c, k, cc;
  while (cin >> n >> k) {
    cc = 0;
    for (i = 0; i < n; i++) {
      cin >> c >> p;
      in[i].sol = c;
      in[i].tim = p;
    }
    sort(in, in + n, cmp);
    for (i = 0; i < n; i++) {
      if (in[k - 1].sol == in[i].sol && in[k - 1].tim == in[i].tim) {
        cc++;
      }
    }
    cout << cc << endl;
  }
  return 0;
}
