#include <bits/stdc++.h>
using namespace std;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first > b.first;
}
int coun[100][100];
int main() {
  int n, x, w, q, ans;
  vector<pair<int, int> > ar;
  cin >> n >> x;
  x--;
  for (int i = 0; i < n; i++) {
    cin >> w >> q;
    coun[w][q]++;
    ar.push_back(make_pair(w, q));
  }
  sort(ar.begin(), ar.end(), cmp);
  cout << coun[ar[x].first][ar[x].second] << endl;
  return 0;
}
