#include <bits/stdc++.h>
using namespace std;
int m[111][111];
struct cc {
  int sum;
  int time;
} yy[111];
int cmp(cc a, cc b) {
  if (a.sum != b.sum)
    return a.sum > b.sum;
  else
    return a.time < b.time;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> yy[i].sum >> yy[i].time;
    m[yy[i].sum][yy[i].time]++;
  }
  sort(yy, yy + n, cmp);
  cout << m[yy[k - 1].sum][yy[k - 1].time] << endl;
}
